QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#528264#6394. Turn on the Lightmegumi#WA 1ms3684kbC++14932b2024-08-23 12:15:362024-08-23 12:15:36

Judging History

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

  • [2024-08-23 12:15:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2024-08-23 12:15:36]
  • 提交

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 = n, ans = 0, x, last = 0;
    cin >> 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: 0
Wrong Answer
time: 1ms
memory: 3684kb

input:

3
1

output:

? 1
? 16349

result:

wrong answer Integer parameter [name=x] equals to 16349, violates the range [1, 3]