# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
819031 | 2023-08-10T07:42:47 Z | Faisal_Saqib | Carnival (CEOI14_carnival) | C++17 | 19 ms | 312 KB |
#include <iostream> #include <set> #include <map> #include <vector> using namespace std; int par[1000]; int get(int x) { if(par[x]==x) { return x; } return par[x]=get(par[x]); } void join(int a,int b) { a=get(a); b=get(b); if(a<b) { par[b]=a; } else { par[a]=b; } } bool match(vector<int> v,int y) { cout<<v.size()+1; for(auto i:v) { cout<<' '<<i; } cout<<' '<<y<<endl; cin>>y; if(y==v.size()) { return 1; } else{ return 0; } } // int solve(vector<int> H,int pe) // { // vector<int> fh,sh; // int mid=(H.size()+1)/2; // for(int i=0;i<H.size();i++) // { // if(i<mid) // { // fh.push_back(H[i]); // } // else // { // sh.pb(H[i]); // } // } // } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { par[i]=i; } // solve(1,n); vector<int> hg={1}; for(int i=2;i<=n;i++) { if(match(hg,i)) { for(auto j:hg) { if(match({j},i)) { join(i,j); break; } } } else { hg.push_back(i); } } cout<<0; int val[n+4]; int cdx=1; for(int i=1;i<=n;i++) { if(get(i)==i) { val[i]=cdx++; } } for(int i=1;i<=n;i++) { cout<<' '<<val[get(i)]; } cout<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 208 KB | Output is correct |
2 | Correct | 11 ms | 208 KB | Output is correct |
3 | Correct | 10 ms | 308 KB | Output is correct |
4 | Correct | 3 ms | 208 KB | Output is correct |
5 | Correct | 3 ms | 208 KB | Output is correct |
6 | Correct | 3 ms | 208 KB | Output is correct |
7 | Correct | 10 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Output is correct |
2 | Correct | 17 ms | 256 KB | Output is correct |
3 | Correct | 11 ms | 304 KB | Output is correct |
4 | Correct | 6 ms | 312 KB | Output is correct |
5 | Correct | 3 ms | 208 KB | Output is correct |
6 | Correct | 2 ms | 208 KB | Output is correct |
7 | Correct | 7 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Output is correct |
2 | Correct | 6 ms | 208 KB | Output is correct |
3 | Correct | 19 ms | 304 KB | Output is correct |
4 | Correct | 4 ms | 208 KB | Output is correct |
5 | Correct | 3 ms | 208 KB | Output is correct |
6 | Correct | 3 ms | 208 KB | Output is correct |
7 | Correct | 16 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Output is correct |
2 | Correct | 6 ms | 208 KB | Output is correct |
3 | Correct | 13 ms | 304 KB | Output is correct |
4 | Correct | 5 ms | 308 KB | Output is correct |
5 | Correct | 3 ms | 208 KB | Output is correct |
6 | Correct | 4 ms | 296 KB | Output is correct |
7 | Correct | 13 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 208 KB | Output is correct |
2 | Correct | 6 ms | 256 KB | Output is correct |
3 | Correct | 16 ms | 208 KB | Output is correct |
4 | Correct | 12 ms | 300 KB | Output is correct |
5 | Correct | 4 ms | 304 KB | Output is correct |
6 | Correct | 3 ms | 312 KB | Output is correct |
7 | Correct | 4 ms | 304 KB | Output is correct |