# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930612 | 2024-02-20T07:56:48 Z | Faisal_Saqib | Colors (BOI20_colors) | C++17 | 0 ms | 344 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Wrong guess |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Wrong guess |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Wrong guess |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Wrong guess |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Wrong guess |
2 | Halted | 0 ms | 0 KB | - |