Submission #1040046

#TimeUsernameProblemLanguageResultExecution timeMemory
1040046vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
6 ms460 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pld pair<ld, ld> #define pb push_back #define fi first #define se second #define debug(x) cerr << #x << " => " << x << endl #define all(x) x.begin(),x.end() int ans[155]; int ask(int x,int y) { cout<<y-x+1<<' '; for(int i=x;i<=y;i++) cout<<i<<' '; cout<<endl; int a;cin>>a; return a; } int sz(int x,int y) { set<int> s; for(int i=x;i<=y;i++) s.insert(ans[i]); return s.size(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n;cin>>n; ans[1]=1; for(int i=2;i<=n;i++) { int a=sz(1,i-1); int b=ask(1,i); if(a!=b) { ans[i]=b; continue; } int l=1,r=i-1,id=1; while(l<=r) { int mid=(l+r)/2; int x=sz(mid,i-1); int y=ask(mid,i); if(x==y) l=mid+1,id=mid; else r=mid-1; } ans[i]=ans[id]; } cout<<0<<' '; for(int i=1;i<=n;i++) cout<<ans[i]<<' '; cout<<endl; 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...