# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166539 | 2019-12-02T17:49:52 Z | wilwxk | Carnival (CEOI14_carnival) | C++14 | 2 ms | 380 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN=155; int rep[MAXN], repp[MAXN]; int mp[MAXN]; int n, cnt; int find(int x) { return rep[x]= rep[x]==x ? x : find(rep[x]); } void une(int a, int b) { a=find(a); b=find(b); if(a==b) return; if(repp[a]>repp[b]) swap(a, b); rep[a]=b; } int main() { scanf("%d", &n); for(int i=1; i<=n; i++) rep[i]=repp[i]=i; for(int i=1; i<=n; i++) { for(int j=1; j<i; j++) { printf("2 %d %d\n", i, j); int x; scanf("%d", &x); if(x==1) une(i, j); fflush(stdout); } } printf("0 "); for(int i=1; i<=n; i++) { if(!mp[find(i)]) mp[find(i)]=++cnt; printf("%d ", mp[find(i)]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2 ms | 252 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2 ms | 248 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 0 ms | 380 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2 ms | 376 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2 ms | 376 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |