QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686508 | #6394. Turn on the Light | libantian# | WA | 1ms | 3704kb | C++23 | 1.1kb | 2024-10-29 13:55:53 | 2024-10-29 13:55:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
// void solve(int l,int r,int y){
// int x;
// printf("? %d\n",r);
// scanf("%d",&x);
// if (x==y) {printf("! %d\n",r); exit(0);}
// y=x;
// int mid=l+r>>1;
// printf("? %d\n",mid);
// scanf("%d",&x);
// if (x==y) {printf("! %d\n",mid); exit(0);}
// if (x==y+1) solve(l,mid-1,x); else solve(mid+1,r,x);
// }
void solve(int l,int r,int y){
int x;
cout<<"? "<<r<<endl;
cin>>x;
if (x==y) {cout<<"! "<<r<<endl; exit(0);}
y=x;
int mid=l+r>>1;
cout<<"? "<<mid<<endl;
cin>>x;
if (x==y) {cout<<"! "<<mid<<endl; exit(0);}
if (x==y+1) solve(l,mid-1,x); else solve(mid+1,r,x);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cout << setiosflags(ios::fixed) << setprecision(15);
int T;
T=1;
//cin>>T;
int n;
cin>>n;
solve(1,n,0);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
input:
3 0
output:
? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3640kb
input:
10 1 0 0
output:
? 10 ? 5 ? 10 ! 10
result:
wrong answer Wrong answer, more than 1 possible light!