# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
466512 | vendx_greyback | Colors (BOI20_colors) | C++14 | 1 ms | 200 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;
#define int long long
#define all(x) (x).begin(),(x).end()
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int left = 1, right = n, query = 1, outcome, last_asked = 1, default_query = 2;
cout<<"? 1"<<endl;
cin>>outcome;
while(left < right){
int mid = left + (right-left)/2;
last_asked = query;
if(query + mid <= n)
query = query + mid;
else if(query - mid >= 1)
query = query - mid;
else
query = default_query;
if(query == default_query)
default_query++;
cout<<"? "<<query<<endl;
cin>>outcome;
if(outcome)
right = min(right,abs(query-last_asked));
else
left = max(left,abs(query-last_asked) + 1);
}
cout<<"= "<<right<<'\n';
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... |