Submission #541439

#TimeUsernameProblemLanguageResultExecution timeMemory
541439status_codingCarnival (CEOI14_carnival)C++14
100 / 100
12 ms292 KiB
#include <bits/stdc++.h> using namespace std; int n,sz,nrG,nr; int a[155]; vector<int> v[155]; int query(int id, int x) { cout<<(int)v[id].size() + 1<<' '; for(int it : v[id]) cout<<it<<' '; cout<<x; cout<<endl; int ans; cin>>ans; return ans; } int query2(int x, int y) { cout<<2<<' '<<x<<' '<<y<<'\n'; cout<<endl; int ans; cin>>ans; return ans; } int main() { cin>>n; sz=sqrt(n); nrG=1; nr=1; a[1]=1; v[1].push_back(1); for(int i=2;i<=n;i++) { bool found = false; for(int j=1;j<=nrG;j++) { if(query(j, i) == (int)v[j].size()) { found = true; for(int it : v[j]) if(query2(it, i) == 1) { a[i] = a[it]; break; } break; } } if(!found) { nr++; a[i]=nr; if((int)v[nrG].size() == sz) nrG++; v[nrG].push_back(i); } } cout<<"0 "; for(int i=1;i<=n;i++) cout<<a[i]<<' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...