#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, s, t;
cin >> n >> s >> t;
vector<vector<int>> g(t);
vector<int> x(n), y(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
--x[i]; --y[i];
g[x[i]].push_back(i);
g[y[i]].push_back(i);
}
vector<vector<int>> res(n, vector<int>(2));
vector<bool> was(n);
vector<bool> rem(n);
function<void(int)> Dfs = [&](int v) {
was[v] = true;
for (int e : g[v]) {
if (rem[e]) {
continue;
}
rem[e] = true;
int u = (x[e] ^ y[e] ^ v);
res[e][0] = v;
res[e][1] = u;
if (!was[u]) {
Dfs(u);
}
}
};
for (int i = 0; i < n; i++) {
if (!was[i]) {
Dfs(i);
}
}
for (int i = 0; i < n; i++) {
cout << res[i][0] + 1 << " " << res[i][1] + 1 << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
15436 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
15436 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
456 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
456 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
456 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
15436 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
15436 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |