QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528337 | #6394. Turn on the Light | hnust_100team# | WA | 1ms | 3704kb | C++17 | 535b | 2024-08-23 12:59:17 | 2024-08-23 12:59:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
int query(int x){
cout<<"? "<<x<<endl;
cout.flush();
int num;
cin>>num;
return num;
}
void solve(){
int n;cin>>n;
int cnt = query(1);
if(cnt==0){
cout<<"! "<<1<<"\n";
return ;
}
int l = 1,r=n;
while(l<r){
int mid=(l+r+1)/2;
if(query(mid)>=cnt) l =mid;
else r=mid-1;
}
cout<<"! "<<l<<"\n";
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
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: 3704kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5 ! 5
result:
wrong answer Wrong favorite light!