이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#define all(x) x.begin(),x.end()
using namespace std;
void output(int num){
cout << "? " << num << endl;
return;
}
void input(bool &ok){
int num;
cin >> num;
ok = bool(num);
return;
}
int main()
{
int n, num; cin >> n;
int high=n, low=1, llast=INT_MIN;
cout << "? 0" << endl;
cin >> num;
while(low<=high){
int mid = (high+low+1)>>1;
output(mid);
bool ok; input(ok);
if(high==low&&!ok) {cout << "= " << llast << endl; return 0;}
else if(high==low&&ok){cout << "= " << mid << endl; return 0;}
if(ok) high = mid-1;
else low = mid+1;
if(ok) llast = mid;
}
cout << "= " << llast << endl;
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... |