QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#528267#6394. Turn on the Lightmegumi#WA 1ms3724kbC++14935b2024-08-23 12:16:312024-08-23 12:16:33

Judging History

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

  • [2024-08-23 12:16:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3724kb
  • [2024-08-23 12:16:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9')
        f = (c == '-') ? -1 : 1, c = getchar();
    while (c >= '0' && c <= '9')
        x = x * 10 + c - 48, c = getchar();
    return f * x;
}
signed main() {
    int n, l = 1, r, ans = 0, x, last = 0;
    cin >> n, r = n;
    while (l <= r) {
        cout << "? " << l << endl;
        int y;
        cin >> y;
        if (y == last) {
            cout << "! " << l << endl;
            return 0;
        }
        last = y;
        int mid = (l + r) >> 1;
        cout << "? " << mid << endl;
        cin >> x;
        if (x == last) {
            cout << "! " << mid << endl;
            return 0;
        }
        if (x == last - 1)
            r = mid - 1;
        else
            l = mid + 1;
        last = x;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
5

output:

? 1
? 5
? 6
? 8
? 9
? 9
! 9

result:

wrong answer Wrong favorite light!