QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528278#6394. Turn on the Lightlsflsf2023#WA 1ms3688kbC++14750b2024-08-23 12:24:172024-08-23 12:24:19

Judging History

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

  • [2024-08-23 12:24:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-08-23 12:24:17]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int ask(int x){
    cout << "? " << x << endl;
    cout.flush();

    cin >> x;
    return x;
}

int main()
{
    int n;
    cin >> n;

    int last = 0;
    int x = ask(1);

    if(x == last){
        cout << "! " << 1 << "\n";
        return 0;
    }

    last = x;

    int l = 2 , r = n;
    while(l < r){
        int mid = (l + r) >> 1;
        x = ask(mid);
        if(x == last){
            cout << "! " << mid << endl;
            return 0;
        }
        if(x > last) {
            l = mid + 1;
            last = x;
        }else {
            r = mid - 1;
            last = x;
        }
    }

    cout << "! " << r << endl;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

3
1
2

output:

? 1
? 2
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3620kb

input:

10
1
0
1
2

output:

? 1
? 6
? 3
? 4
! 5

result:

wrong answer Wrong answer, more than 1 possible light!