이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)
using namespace std;
void solve(ll _) {
ll n; cin>>n;
if(n == 1) {
cout<<"= 1"<<endl;
return;
}
cout<<"? "<<1<<endl;
bool curr; cin>>curr;
ll ans = 0;
ll last = 1, now = n;
bool left = true;
while(true) {
cout<<"? "<<now<<endl;
cin>>curr;
if(curr == 1) ans = abs(now - last);
ll temp = last;
last = now;
now = temp + (left ? 1 : -1);
if(now == last) break;
left = !left;
}
cout<<"= "<<ans<<endl;
}
int main() {
fastIO
//freopen("file.in", "r", stdin);
//freopen("file.out", "w", stdout);
ll t = 0; solve(t);
}
# | 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... |