# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930612 | Faisal_Saqib | Colors (BOI20_colors) | C++17 | 0 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |