QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417544 | #6394. Turn on the Light | LCJ | WA | 1ms | 3588kb | C++14 | 633b | 2024-05-22 19:39:22 | 2024-05-22 19:39:23 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,m,k,q,ans;
int ask(int x){
cout<<"? "<<x<<endl;
//cout.flush();
int res;
cin>>res;
return res;
}
void solve(){
cin>>n;
k=0;
for(int i=1;i<=1;i++){
int kk=ask(i);
if(k==kk){
cout<<"! "<<i<<endl;
return;
}
k=kk;
}
k=1;
int l=2,r=n;
while(l<=r){
int mid=(l+r)/2;
ans=ask(mid);
if(ans==k){
cout<<"! "<<mid<<endl;
return;
}
if(k<ans){
l=mid+1;
}
else{
r=mid-1;
}
k=ans;
}
}
signed main(){
int T=1;
//cin>>T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3496kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected