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;
const int C = 35;
int prv = 0;
bool query( long long c ) {
cout << "? " << c << endl;
bool ans = (abs( prv - c ) >= C);
prv = c;
cout << ans << endl;
return ans;
}
/*bool query( long long c ) {
cout << "? " << c << endl;
bool ans;
cin >> ans;
return ans;
}*/
void answer( long long c ) {
cout << "= " << c << endl;
}
int main() {
long long n;
cin >> n;
query( n / 2 );
int l = n - (1 << ((int)log2( n ))), c = 0;
for ( int k = log2( n ); k >= 0; k-- ) {
if ( c + (1 << k) >= n )
continue;
if ( l > n / 2 ) {
l -= c + (1 << k);
if ( !query( l ) )
c += (1 << k);
} else {
l += c + (1 << k);
if ( !query( l ) )
c += (1 << k);
}
}
answer( c + 1 );
return 0;
}
# | 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... |