QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371624#6394. Turn on the Lighthuangxi#WA 1ms3820kbC++17824b2024-03-30 14:31:322024-03-30 14:34:15

Judging History

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

  • [2024-03-30 14:34:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3820kb
  • [2024-03-30 14:31:32]
  • 提交

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!