Submission #996002

#TimeUsernameProblemLanguageResultExecution timeMemory
996002vjudge1Carnival (CEOI14_carnival)C++14
0 / 100
8 ms344 KiB
//#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,fma,lzcnt,popcnt") #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define pf push_front #define ii pair<int,int> #define ill pair<ll,ll> #define el cout<<'\n' const ll mod=1e9+7; const int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; const int nmax=1e5; void add ( int&a , int b ) { if ((a+=b) > mod ) a -= mod ; } void sub ( int&a , int b ) { if ((a-=b) < 0 ) a += mod ; } template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;} template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;} using namespace std; vector<int>a; int cnt=0; int ans[nmax+5]; vector<int>dele; bool check(int l,int r,int st) { int tmp1=1,tmp2; if(r>l){ cout<<(r-l+1)<<" "; for(int i=l;i<=r;i++) cout<<a[i]<<" "; //fflush(stdout); cin>>tmp1; } cout<<(r-l+2)<<" "<<st<<" "; for(int i=l;i<=r;i++) cout<<a[i]<<" "; // fflush(stdout); cin>>tmp2; // cout<<l<<" "<<r return(tmp1==tmp2); } void segment(int l,int r,int st) { //int mid=(l+r)/2; //if(l>r) // return; if(l==r) { dele.pb(a[l]); ans[a[l]]=cnt; return ; } int mid=(l+r)/2; if(check(l,mid,st)) {segment(l,mid,st); if(check(mid+1,r,st)) segment(mid+1,r,st); } else { segment(mid+1,r,st); } } int main() { ios::sync_with_stdio(0); // cin.tie(0);cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) a.pb(i); while(!a.empty()) { cnt++; ans[a[0]]=cnt; if(a.size()==1) { break; } int tmp=a[0]; dele.clear(); segment(1,a.size()-1,tmp); sort(dele.begin(),dele.end(),greater<int>()); for(auto i:dele){ auto it = find(a.begin(), a.end(),i); // cout<<i<<" "; a.erase(it); } // cout<<a.size()<<"wtf";el; //if() if(!a.empty()){ auto it=a.begin(); a.erase(it); } // cout<<a.size()<<" "<<a[0]<<"jj";el; } cout<<"0 "; for(int i=1;i<=n;i++) cout<<ans[i]<<" "; }
#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...