QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407472#6394. Turn on the Lightnageing#WA 1ms3604kbC++20628b2024-05-08 19:25:432024-05-08 19:25:43

Judging History

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

  • [2024-05-08 19:25:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-05-08 19:25:43]
  • 提交

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;
    while (l < r) {
        int mid = l + r >> 1;
        int x = query(mid);
        if (x > 0) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    cout << "! " << l - 1 << '\n';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3592kb

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3

output:

? 5
? 8
? 10
! 10

result:

wrong answer Wrong answer, more than 1 possible light!