# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1085989 |
2024-09-09T08:57:42 Z |
juicy |
Pipes (CEOI15_pipes) |
C++17 |
|
708 ms |
22868 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e5;
struct dsu {
int pr[N];
dsu() {
memset(pr, -1, sizeof(pr));
}
int find(int u) {
return pr[u] < 0 ? u : pr[u] = find(pr[u]);
}
bool mrg(int u, int v) {
if ((u = find(u)) == (v = find(v))) {
return 0;
}
pr[v] = u;
return 1;
}
} a, b;
int n, m;
int low[N], num[N];
vector<int> g[N];
int timer;
void dfs(int u, int p) {
low[u] = num[u] = ++timer;
bool flg = 0;
for (int v : g[u]) {
if (v == p && !flg) {
flg = 1;
continue;
}
if (!num[v]) {
dfs(v, u);
low[u] = min(low[u], low[v]);
if (low[v] > num[u]) {
cout << u + 1 << " " << v + 1 << "\n";
}
} else {
low[u] = min(low[u], num[v]);
}
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
while (m--) {
int u, v; cin >> u >> v; --u, --v;
if (a.mrg(u, v)) {
g[u].push_back(v);
g[v].push_back(u);
} else if (b.mrg(u, v)) {
g[u].push_back(v);
g[v].push_back(u);
}
}
for (int i = 0; i < n; ++i) {
if (!num[i]) {
dfs(i, i);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3932 KB |
Output is correct |
2 |
Correct |
3 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3920 KB |
Output is correct |
2 |
Correct |
53 ms |
3672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
4432 KB |
Output is correct |
2 |
Correct |
107 ms |
3928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
5968 KB |
Output is correct |
2 |
Correct |
138 ms |
5508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
10972 KB |
Output is correct |
2 |
Correct |
198 ms |
7352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
11944 KB |
Output is correct |
2 |
Correct |
338 ms |
9040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
470 ms |
13980 KB |
Output is correct |
2 |
Correct |
446 ms |
9108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
621 ms |
13988 KB |
Output is correct |
2 |
Correct |
548 ms |
9044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
708 ms |
13516 KB |
Output is correct |
2 |
Runtime error |
693 ms |
22868 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |