QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371624 | #6394. Turn on the Light | huangxi# | WA | 1ms | 3820kb | C++17 | 824b | 2024-03-30 14:31:32 | 2024-03-30 14:34:15 |
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 query(int x){
int cur;
cout<<"? "<<x<<endl;
cout.flush();
cin>>cur;
return cur;
}
void dfs(int l,int r,int x){
int cur=l+r>>1;
int y=query(cur);
if(y==abs(x)) {
cout<<"! "<<cur<<endl;
flag=true;
return;
}
if(x==0){
if(flag) return;
dfs(cur+1,r,-1);
if(flag) return;
dfs(l,cur,1);
}else if(x<0){
if(y<x) dfs(cur+1,r,-y);
else dfs(l,cur,-y);
}else{
if(y>x) dfs(l,cur,y);
else dfs(cur+1,r,y);
}
}
int main() {
scanf("%d",&n);
int l=1,r=n;
dfs(1,n,0);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3820kb
input:
10 1 2 3 4 4
output:
? 5 ? 8 ? 7 ? 6 ? 6 ! 6
result:
wrong answer Wrong answer, more than 1 possible light!