QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407493#6394. Turn on the Lightnageing#WA 0ms3600kbC++20882b2024-05-08 19:59:382024-05-08 19:59:39

Judging History

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

  • [2024-05-08 19:59:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-05-08 19:59:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int query(int x) {
    cout << "? " << x << endl;
    int res;
    cin >> res;
    return res;
}

void solve() {
    int n;
    cin >> n;
    int l = 0, r = n + 1;
    int cnt1 = 0, cnt2 = 0;
    while (l < r) {
        int mid = l + r >> 1;
        int x = query(mid);
        if (x < 0 && x == cnt2) {
            cout << "! " << mid << '\n';
            return;
        } else if (x >= 0 && x == cnt1) {
            cout << "! " << mid << '\n';
            return;
        }
        if (x > 0) {
            l = mid + 1;
            cnt1 = x;
        } else {
            r = mid;
            cnt2 = x;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int t;
    t = 1;
    while (t --) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3

output:

? 5
? 8
? 10

result:

wrong answer format  Unexpected end of file - token expected