# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534631 | 2022-03-08T12:15:41 Z | shrimb | Carnival (CEOI14_carnival) | C++17 | 118 ms | 200 KB |
#include"bits/stdc++.h" #define int long long // #define endl '\n' using namespace std; int dsu[20001]; int ans[20001]; int Find (int x) { return dsu[x] == x ? x : dsu[x] = Find(dsu[x]); } void Union (int a, int b) { dsu[Find(a)] = Find(b); } bool Query (int a, int b) { cout << "2 " << a << " " << b << endl; int x; cin >> x; return x == 1; } bitset<151> vis; signed main () { srand(time(0)); int n; cin >> n; for (int i = 1 ; i <= n ; i++) dsu[i] = i; for (int i = 1 ; i <= n ; i++) { vis = 0; vis[i] = 1; for (int j = 0 ; j < n ; j++) { int x = rand() % n + 1; if (vis[x]) {j-=(vis.count() < n); continue;} else { vis[x] = 1; if (Query(i, x)) Union(i, x); } } } int c = 1; for (int i = 1 ; i <= n ; i++) if (dsu[i] == i) ans[i] = c++; cout << 0 << " "; for (int i = 1 ; i <= n ; i++) cout << ans[Find(i)] << " "; cout << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 84 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 114 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 118 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 116 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 57 ms | 200 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |