0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 22:28:48 +00:00

Compare commits

...

4 Commits

193 changed files with 881 additions and 0 deletions

91
LibreOJ/2162/2162.cpp Normal file
View File

@ -0,0 +1,91 @@
#include <iostream>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5,
M = 1e6 + 5;
int n, m, d[N], root;
bool vis[N], in_stack[N], edge_used[M];
std::stack<int> st;
std::vector<std::pair<int, int>> g[N];
std::vector<std::vector<int>> ans;
void dfs(int u) {
vis[u] = true;
for (auto e : g[u]) {
int v = e.first,
id = e.second;
if (edge_used[id]) continue;
edge_used[id] = true;
dfs(v);
}
if (in_stack[u]) {
std::vector<int> res{u};
while (st.top() != u) {
res.emplace_back(st.top());
in_stack[st.top()] = false;
st.pop();
}
res.emplace_back(u);
ans.emplace_back(res);
} else {
st.push(u);
in_stack[u] = true;
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1, a, b, s, t; i <= m; i++) {
cin >> a >> b >> s >> t;
if (s ^ t) {
g[a].emplace_back(b, i);
g[b].emplace_back(a, i);
d[a]++, d[b]++;
}
}
for (int i = 1; i <= n; i++) {
if (d[i] % 2 != 0) {
cout << "NIE" << endl;
exit(0);
}
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) dfs(i);
}
cout << ans.size() << endl;
for (auto& item : ans) {
cout << item.size() - 1 << ' ';
for (int& x : item) {
cout << x << ' ';
}
cout << endl;
}
return 0;
}

BIN
LibreOJ/2162/data/checker.cpp (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi0.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi0.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi0a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi0a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi10a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi10a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi10b.ine (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi10b.oute (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi1ocen.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi1ocen.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi2ocen.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi2ocen.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3b.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3b.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3ocen.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi3ocen.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4b.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4b.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4ocen.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi4ocen.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5b.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5b.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5ocen.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi5ocen.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi6a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi6a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi6b.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi6b.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi7a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi7a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi7b.ine (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi7b.oute (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi8a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi8a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi8b.ine (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi8b.oute (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi9a.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi9a.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi9b.ine (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/smi9b.oute (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2162/data/spj_cpp.cpp (Stored with Git LFS) Normal file

Binary file not shown.

91
Luogu/P3520/P3520.cpp Normal file
View File

@ -0,0 +1,91 @@
#include <iostream>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5,
M = 1e6 + 5;
int n, m, d[N], root;
bool vis[N], in_stack[N], edge_used[M];
std::stack<int> st;
std::vector<std::pair<int, int>> g[N];
std::vector<std::vector<int>> ans;
void dfs(int u) {
vis[u] = true;
for (auto e : g[u]) {
int v = e.first,
id = e.second;
if (edge_used[id]) continue;
edge_used[id] = true;
dfs(v);
}
if (in_stack[u]) {
std::vector<int> res{u};
while (st.top() != u) {
res.emplace_back(st.top());
in_stack[st.top()] = false;
st.pop();
}
res.emplace_back(u);
ans.emplace_back(res);
} else {
st.push(u);
in_stack[u] = true;
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1, a, b, s, t; i <= m; i++) {
cin >> a >> b >> s >> t;
if (s ^ t) {
g[a].emplace_back(b, i);
g[b].emplace_back(a, i);
d[a]++, d[b]++;
}
}
for (int i = 1; i <= n; i++) {
if (d[i] % 2 != 0) {
cout << "NIE" << endl;
exit(0);
}
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) dfs(i);
}
cout << ans.size() << endl;
for (auto& item : ans) {
cout << item.size() - 1 << ' ';
for (int& x : item) {
cout << x << ' ';
}
cout << endl;
}
return 0;
}

44
S2OJ/1562/1562.cpp Normal file
View File

@ -0,0 +1,44 @@
#include <iostream>
#include <algorithm>
#include <set>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, k, ans;
std::pair<int, int> a[N];
std::multiset<int> set;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
}
std::sort(a + 1, a + 1 + n, [&](const std::pair<int, int> &a, const std::pair<int, int> &b) {
return a.second < b.second;
});
for (int i = 1; i <= k; i++) set.insert(0);
for (int i = 1; i <= n; i++) {
auto it = set.upper_bound(a[i].first);
if (it != set.begin()) {
set.erase(--it);
set.insert(a[i].second);
ans++;
}
}
cout << ans << endl;
return 0;
}

BIN
S2OJ/1562/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1562/data/tv29.out (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More