Submission #677565

#TimeUsernameProblemLanguageResultExecution timeMemory
677565sofija6Carnival (CEOI14_carnival)C++14
100 / 100
25 ms336 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 160 using namespace std; ll d[MAXN]; ll Root(ll p) { while (p!=d[p]) { d[p]=d[d[p]]; p=d[p]; } return p; } void Join(ll p,ll q) { d[Root(p)]=d[Root(q)]; } int main() { ///ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; for (ll i=1;i<=n;i++) d[i]=i; for (ll i=2;i<=n;i++) { ll l=1,r=i-1,mid,x,y; cout << i << " "; for (ll j=1;j<=i;j++) cout << j << " "; cout << "\n"; cin >> x; cout << i-1 << " "; for (ll j=1;j<i;j++) cout << j << " "; cout << "\n"; cin >> y; if (x!=y) continue; while (l<=r) { mid=(l+r)/2; cout << mid-l+1 << " "; for (ll j=l;j<=mid;j++) cout << j << " "; cout << "\n"; cin >> x; cout << mid-l+2 << " "; for (ll j=l;j<=mid;j++) cout << j << " "; cout << i << "\n"; cin >> y; if (y==1) { Join(i,mid); break; } if (x==y) r=mid; else l=mid+1; } } ll cnt=1; map<ll,ll> ans; cout << 0 << " "; for (ll i=1;i<=n;i++) { if (!ans[Root(i)]) { ans[Root(i)]=cnt; cnt++; } cout << ans[Root(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...