QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#251993 | #6394. Turn on the Light | ucup-team1074 | WA | 1ms | 3708kb | C++17 | 1.3kb | 2023-11-15 14:09:40 | 2023-11-15 14:09:40 |
Judging History
answer
#include<iostream>
#include<math.h>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#define ll long long
using namespace std;
int a[100010];
int b[100010];
void solve()
{
int n;
cin>>n;
int l=2,r=n;
int res1=0;
int res2=0;
int len=0;
int ans[50];
cout<<"? "<<1<<endl;
++len;
cin>>ans[len];
while(1)
{
if(ans[len]==0)
{
cout<<"? "<<l<<endl;
++len;
cin>>ans[len];
if(ans[len]==0)
{
cout<<"! "<<l<<endl;
break;
}
else
l++;
}
int mid =(l+r)>>1;
cout<<"? "<<mid<<endl;
++len;
cin>>ans[len];
if(ans[len]==ans[len-1])
{
cout<<"! "<<mid<<endl;
break;
}
else if(ans[len]>ans[len-1])
{
l=mid+1;
}
else
{
r=mid-1;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
int t;
t=1;
while(t>0)
{
t--;
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
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: 1ms
memory: 3708kb
input:
9 1 2 3 3
output:
? 1 ? 5 ? 7 ? 8 ! 8
result:
ok Correct position at 8
Test #4:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
8 1 0 1 1
output:
? 1 ? 5 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #5:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
7 1 2 3 3
output:
? 1 ? 4 ? 6 ? 7 ! 7
result:
ok Correct position at 7
Test #6:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
6 1 0 1 1
output:
? 1 ? 4 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #7:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
5 1 2 3 3
output:
? 1 ? 3 ? 4 ? 5 ! 5
result:
ok Correct position at 5
Test #8:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
4 1 1
output:
? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #9:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
3 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: -100
Wrong Answer
time: 1ms
memory: 3576kb
input:
1 0
output:
? 1 ? 2
result:
wrong answer Integer parameter [name=x] equals to 2, violates the range [1, 1]