QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108185 | #6394. Turn on the Light | Liberty12619# | WA | 3ms | 3616kb | C++20 | 926b | 2023-05-23 20:09:29 | 2023-05-23 20:10:55 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 2e5+10,M = 1<<24,mod = 1e9+7,INF=1e9;
typedef pair<int,int>PII;
int query(int x)
{
int res;
cout<<"? "<<x<<endl;
cin>>res;
return res;
}
void solve()
{
int n;
cin>>n;
int l=1,r=n,last=0;
while(l<r)
{
int mid = l+r+1>>1;
int t = query(mid);
if(t==last)
{
cout<<"! "<<mid<<endl;
return;
}
last=t;
t = query(l);
if(t==last)
{
cout<<"! "<<l<<endl;
return;
}
if(t==last-1)
{
l++;
r=mid-1;
}
else l=mid+1;
}
cout<<"! "<<l<<endl;
}
signed main()
{
int T =1;
//cin>>T;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3616kb
input:
3 1 2
output:
? 2 ? 1 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3316kb
input:
10 1 0 1
output:
? 6 ? 1 ? 4 ! 4
result:
wrong answer Wrong answer, more than 1 possible light!