Submission #1051502

#TimeUsernameProblemLanguageResultExecution timeMemory
1051502MilosMilutinovicBrought Down the Grading Server? (CEOI23_balance)C++14
0 / 100
42 ms15436 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...