QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387314#6394. Turn on the LightDog_E#WA 0ms3668kbC++20958b2024-04-12 13:10:592024-04-12 13:11:00

Judging History

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

  • [2024-04-12 13:11:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2024-04-12 13:10:59]
  • 提交

answer

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

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

void print(int x) {
    cout << "! " << x << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int l = 1, r = n;
    int last, now;
    last = ask(1);
    if (last == 0) {
        print(1);
        return 0;
    }
    int mid = l + r >> 1;
    now = ask(mid);
    if (now == last) {
        print(mid);
        return 0;
    }
    if (now == 0) {
        r = mid - 1;
        last = now;
        now = ask(n);
    } else {
        l = mid + 1;
        last = now;
    }
    while (l < r) {
        mid = l + r >> 1;
        last = now;
        now = ask(mid);
        if (now == last) {
            print(mid);
            return 0;
        }
    }
    cout << l << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

input:

3
1
2

output:

? 1
? 2
3

result:

wrong answer Token parameter [name=type] equals to "3", doesn't correspond to pattern "?|!"