QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371749 | #6394. Turn on the Light | huangxi# | WA | 1ms | 3820kb | C++17 | 878b | 2024-03-30 15:31:17 | 2024-03-30 15:31:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef long long LL;
const int N=1e3+10,M=510;
int n,m;
pair<int,int>a[N],b[N];
bool flag;
int x;
int query(int x){
int cur;
cout<<"? "<<x<<endl;
cout.flush();
cin>>cur;
return cur;
}
int main() {
scanf("%d",&n);
int l=1,r=n;
int pe=0;
while(l<=r){
int cur=query(l);
if(cur==pe){
cout<<"! "<<l<<endl;
cout.flush();
break;
}
l++;
pe++;
if(l>r) break;
int mid=l+r>>1;
cur=query(mid);
if(cur==pe-1){
r=mid-1;
}else if(cur==pe){
cout<<"! "<<l<<endl;
cout.flush();
break;
}else {
l=mid+1;
}
pe=cur;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
10 1 0 1 0 0
output:
? 1 ? 6 ? 2 ? 4 ? 3 ! 3
result:
ok Correct position at 3
Test #3:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
9 1 2 3 2 2
output:
? 1 ? 5 ? 6 ? 8 ? 7 ! 7
result:
ok Correct position at 7
Test #4:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
8 1 0 1 1
output:
? 1 ? 5 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #5:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
7 1 2 3 3
output:
? 1 ? 4 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #6:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
6 1 0 1 1
output:
? 1 ? 4 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #7:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
5 1 2 3 3
output:
? 1 ? 3 ? 4 ? 5 ! 5
result:
ok Correct position at 5
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3660kb
input:
4 1 1
output:
? 1 ? 3 ! 2
result:
wrong answer Wrong favorite light!