QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371733 | #6394. Turn on the Light | TANGTANGCC | WA | 1ms | 3788kb | C++23 | 1.0kb | 2024-03-30 15:17:39 | 2024-03-30 15:17:41 |
Judging History
answer
#include <bits/stdc++.h>
#include <sstream>
//#define int long long
#define endl '\n'
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
using namespace std;
const int N=1e6+50;
int sz[N];
signed main() {
int n,x;
cin>>n;
int a;
printf("? 1\n");
cin>>a;
int l=1,r=n;
if(a==0) {
printf("! 1");
return 0;
}
l=2;
while(l<r) {
int m=((l+r)>>1)+1;
printf("? %d\n",m);
cin>>x;
if(x==0 and a==1) {
a=x;
r=m-1;
printf("? %d\n",l);
cin>>x;
if(a==x) {
printf("! %d",l);
return 0;
}
a=x;
continue;
}
if(x==a) {
printf("! %d",m);
return 0;
}
else if(x==a+1) {
l=m+1;
}
else if(x==a-1) {
r=m-1;
}
a=x;
}
printf("! %d",l);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3784kb
input:
3 1 1
output:
? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3788kb
input:
10 1 0 1 0 0
output:
? 1 ? 7 ? 2 ? 5 ? 2 ! 2
result:
wrong answer Wrong answer, more than 1 possible light!