QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402273#6394. Turn on the Lightiwew#WA 0ms3584kbC++20759b2024-04-30 10:42:552024-04-30 10:42:56

Judging History

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

  • [2024-04-30 10:42:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-04-30 10:42:55]
  • 提交

answer

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int l = 1, r = n, lstd = 0;

    auto ask = [&](int mid) -> int {
        cout << "? " << mid << endl;
        int d;
        cin >> d;
        return d;
    };

    int ans = -1;
    while(l < r) {
        int mid = (l + r) >> 1;
        auto curd = ask(mid);
        if(curd - lstd == 0) {
            ans = mid;
            break;
        } else if(curd - lstd == 1) {
            l = mid + 1;
        } else {
            r = mid - 1;
        }
        lstd = curd;
    }
    if(ans == -1) ans = l;
    cout << ans << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1

output:

? 2
3

result:

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