# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534636 | 2022-03-08T12:21:32 Z | shrimb | Carnival (CEOI14_carnival) | C++17 | 60 ms | 584 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); } int asked[151][151]; bool Query (int a, int b) { if (asked[a][b] != -1) return asked[a][b]; if (Find(a) == Find(b)) return asked[a][b] = asked[b][a] = 1; cout << "2 " << a << " " << b << endl; int x; cin >> x; return asked[a][b] = asked[b][a] = (x == 1); } bitset<151> vis; signed main () { srand(time(0)); memset(asked, -1, sizeof asked); 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 < 50 ; 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 | Partially correct | 59 ms | 456 KB | Partially correct |
2 | Incorrect | 53 ms | 456 KB | Integer 43 violates the range [1, 37] |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 36 ms | 456 KB | Partially correct |
2 | Incorrect | 50 ms | 460 KB | Integer 29 violates the range [1, 28] |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 584 KB | Output is correct |
2 | Partially correct | 50 ms | 456 KB | Partially correct |
3 | Incorrect | 44 ms | 456 KB | Integer 69 violates the range [1, 58] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 44 ms | 472 KB | Partially correct |
2 | Partially correct | 30 ms | 460 KB | Partially correct |
3 | Incorrect | 32 ms | 476 KB | Integer 121 violates the range [1, 120] |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 456 KB | Output is correct |
2 | Partially correct | 47 ms | 456 KB | Partially correct |
3 | Incorrect | 60 ms | 460 KB | Integer 93 violates the range [1, 89] |
4 | Halted | 0 ms | 0 KB | - |