# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043385 |
2024-08-04T09:00:15 Z |
Pekiban |
Pipes (CEOI15_pipes) |
C++17 |
|
859 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1e5+5;
mt19937 rng(time(0));
// upravo sam imao najgenijalniju ideju svih vremena
vector<int> g[N];
int p[N], dp[N], vis[N];
int get(int x) {
if (x == p[x]) return x;
return p[x] = get(p[x]);
}
bool unite(int u, int v) {
p[get(v)] = get(u);
return 1;
}
void upd(int u, int v) {
int x = rng() % (1LL << 31);
dp[u] ^= x;
dp[v] ^= x;
}
void dfs(int &s, int &e) {
for (auto &u : g[s]) {
if (u == e) continue;
dfs(u, s);
dp[s] ^= dp[u];
}
if (e && !dp[s]) cout << e << ' ' << s << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
iota(p, p+N, 0);
int n, m;
cin >> n >> m;
int u, v;
for (int i = 0; i < m; ++i) {
cin >> u >> v;
if (unite(u, v)) {
g[u].pb(v), g[v].pb(u);
}
else {
upd(u, v);
}
}
for (int i = 1; i <= n; ++i) {
if (!vis[get(i)]) {
int p = get(i), z = 0;
dfs(p, z);
vis[get(i)] = 1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
41 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
91 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
148 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
218 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
287 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
504 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
706 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
745 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
859 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |