Submission #930612

#TimeUsernameProblemLanguageResultExecution timeMemory
930612Faisal_SaqibColors (BOI20_colors)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; void found(int c) { cout<<"= "<<c<<endl; exit(0); } int query(int x) { cout<<"? "<<x<<endl; int p; cin>>p; return p; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int n; cin>>n; query(1); int pr=(n+1)/2; if(query((n+1)/2)) { int s=2; int e=((n+1)/2)-1; int p=((n+1)/2)-1; while(s<=e) { if(query(s) and pr!=-1) p=min(p,abs(s-pr)); pr=s; s++; if(s>e) continue; if(query(e)) p=min(p,abs(e-pr)); pr=e; e--; } found(p); } else{ int s=((n+1)/2)+1; int e=e; int p=n; while(s<=e) { if(query(s) and pr!=-1) p=min(p,abs(s-pr)); pr=s; s++; if(s>e) continue; if(query(e)) p=min(p,abs(e-pr)); pr=e; e--; } found(p); } return 0; }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:47:13: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |         int e=e;
      |             ^
#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...