# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574948 | 2022-06-09T13:19:13 Z | 1zaid1 | Carnival (CEOI14_carnival) | C++14 | 110 ms | 10704 KB |
#include <bits/stdc++.h> using namespace std; // #define endl '\n' const int M = 2e5+5, MOD = 1000000007; #define int long long int rnk[M], clr[M], p[M]; set<int> nono[M]; int find(int s) { return (s == p[s]?s:p[s]=find(p[s])); } void uni(int a, int b) { if (rnk[a] < rnk[b]) swap(a, b); if (rnk[a] == rnk[b]) rnk[a]++; p[b] = a; clr[a] = min(clr[a], clr[b]); } signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for (int i = 1; i <= n; i++) clr[i] = p[i] = i; for (int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { bool check = 1; for (int k:nono[j]) { if (find(i) == find(k)) check = 0; } for (int k:nono[i]) { if (find(j) == find(k)) check = 0; } if (find(i) != find(j) && check) { cout << 2 << ' ' << i << ' ' << j << endl; int x; cin >> x; if (x == 1) uni(find(i), find(j)); else { nono[find(i)].insert(find(j)); nono[find(j)].insert(find(i)); } } } } map<int, int> mp; set<int> st; for (int i = 1; i <= n; i++) st.insert(find(i)); int cnt = 1; for (int i:st) mp[i] = cnt++; cout << 0 << ' '; for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl; return 0; } /* 3 0 3 0 3 0 0 5 4 0 3 1 1 1 3 0 1 4 5 1 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 9680 KB | Output is correct |
2 | Correct | 27 ms | 9896 KB | Output is correct |
3 | Partially correct | 73 ms | 10216 KB | Partially correct |
4 | Partially correct | 108 ms | 10436 KB | Partially correct |
5 | Correct | 7 ms | 9680 KB | Output is correct |
6 | Correct | 7 ms | 9728 KB | Output is correct |
7 | Correct | 21 ms | 9816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 9680 KB | Output is correct |
2 | Correct | 24 ms | 9872 KB | Output is correct |
3 | Partially correct | 54 ms | 10072 KB | Partially correct |
4 | Partially correct | 57 ms | 10500 KB | Partially correct |
5 | Correct | 8 ms | 9680 KB | Output is correct |
6 | Correct | 7 ms | 9680 KB | Output is correct |
7 | Correct | 13 ms | 9776 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 9680 KB | Output is correct |
2 | Correct | 12 ms | 9744 KB | Output is correct |
3 | Partially correct | 34 ms | 10168 KB | Partially correct |
4 | Partially correct | 90 ms | 10560 KB | Partially correct |
5 | Correct | 8 ms | 9736 KB | Output is correct |
6 | Correct | 12 ms | 9680 KB | Output is correct |
7 | Correct | 29 ms | 9832 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9744 KB | Output is correct |
2 | Correct | 7 ms | 9736 KB | Output is correct |
3 | Partially correct | 86 ms | 10472 KB | Partially correct |
4 | Partially correct | 102 ms | 10704 KB | Partially correct |
5 | Correct | 15 ms | 9808 KB | Output is correct |
6 | Correct | 31 ms | 9936 KB | Output is correct |
7 | Correct | 29 ms | 9892 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9680 KB | Output is correct |
2 | Correct | 21 ms | 9800 KB | Output is correct |
3 | Partially correct | 78 ms | 10184 KB | Partially correct |
4 | Partially correct | 71 ms | 10320 KB | Partially correct |
5 | Correct | 39 ms | 9932 KB | Output is correct |
6 | Partially correct | 74 ms | 10172 KB | Partially correct |
7 | Partially correct | 110 ms | 10612 KB | Partially correct |