QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371643#6394. Turn on the Lighthuangxi#WA 0ms3776kbC++17834b2024-03-30 14:39:242024-03-30 14:39:29

Judging History

你现在查看的是最新测评结果

  • [2024-03-30 14:39:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-03-30 14:39:24]
  • 提交

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>abs(x)) dfs(cur+1,r,-y);
        else dfs(l,cur,-y);
    }else{
        if(y>abs(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: 3688kb

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3776kb

input:

10
1
2
3
4
4

output:

? 5
? 8
? 9
? 10
? 10
! 10

result:

wrong answer Wrong answer, more than 1 possible light!