# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
851495 |
2023-09-20T01:29:35 Z |
Nhoksocqt1 |
Pipes (CEOI15_pipes) |
C++17 |
|
753 ms |
14224 KB |
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
vector<int> adj[MAXN];
int lab[MAXN][2];
int root(int it, int u) {
return (lab[u][it] == u) ? u : (lab[u][it] = root(it, lab[u][it]));
}
void dfs(int u, int p) {
lab[u][0] = lab[u][1] = ++lab[0][0];
bool edgep(1);
for (int v : adj[u]) {
if(v == p && edgep) {
edgep = 0;
continue;
}
if(!lab[v][1]) {
dfs(v, u);
lab[u][0] = min(lab[u][0], lab[v][0]);
if(lab[v][0] >= lab[v][1])
cout << u << ' ' << v << '\n';
} else {
lab[u][0] = min(lab[u][0], lab[v][1]);
}
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int numNode, numEdge;
cin >> numNode >> numEdge;
for (int i = 1; i <= numNode; ++i)
lab[i][0] = lab[i][1] = i;
for (int i = 0; i < numEdge; ++i) {
int u, v;
cin >> u >> v;
if(root(0, u) != root(0, v)) {
lab[lab[u][0]][0] = lab[v][0];
adj[u].push_back(v);
adj[v].push_back(u);
} else
if(root(1, u) != root(1, v)) {
lab[lab[u][1]][1] = lab[v][1];
adj[u].push_back(v);
adj[v].push_back(u);
}
}
for (int i = 0; i <= numNode; ++i)
lab[i][0] = lab[i][1] = 0;
for (int i = 1; i <= numNode; ++i) {
if(!lab[i][1])
dfs(i, -1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3672 KB |
Output is correct |
2 |
Correct |
3 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
3564 KB |
Output is correct |
2 |
Correct |
62 ms |
3416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
4368 KB |
Output is correct |
2 |
Correct |
125 ms |
3840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
5968 KB |
Output is correct |
2 |
Correct |
153 ms |
5588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
11088 KB |
Output is correct |
2 |
Correct |
226 ms |
6996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
397 ms |
12196 KB |
Output is correct |
2 |
Correct |
348 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
492 ms |
14160 KB |
Output is correct |
2 |
Correct |
475 ms |
8360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
670 ms |
14224 KB |
Output is correct |
2 |
Correct |
568 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
753 ms |
13512 KB |
Output is correct |
2 |
Correct |
706 ms |
10260 KB |
Output is correct |