Submission #549192

#TimeUsernameProblemLanguageResultExecution timeMemory
549192krit3379Library (JOI18_library)C++17
0 / 100
37 ms336 KiB
#include<bits/stdc++.h> using namespace std; #include"library.h" #define N 1005 bitset<N> vis; vector<int> now,ans; void Solve(int n){ int i,sz,x,y,head,l,r,mid,cnt; now.resize(n); for(i=0;i<n;i++)now[i]=1; for(i=0;i<n;i++){ now[i]=0; x=Query(now); now[i]=1; if(x==1){head=i;break;} } for(i=0;i<n;i++)now[i]=0; vis[head]=true; ans.push_back(head+1); for(sz=n-1;sz>0;sz--){ l=1,r=sz; while(l<r){ mid=(l+r)/2; for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=1,cnt++; x=Query(now); now[head]=1; y=Query(now); now[head]=0; for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=0,cnt++; if(x==y)r=mid; else l=mid+1; } for(i=0,cnt=0;i<n&&cnt<l;i++)if(!vis[i])cnt++; ans.push_back(i); head=i-1; vis[head]=true; } Answer(ans); return ; }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:21:23: warning: 'head' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |     ans.push_back(head+1);
      |                   ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...