QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574725#6394. Turn on the LightGammaRaysWA 1ms3652kbC++23937b2024-09-19 00:06:382024-09-19 00:06:39

Judging History

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

  • [2024-09-19 00:06:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-09-19 00:06:38]
  • 提交

answer

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

void answer(int x) {
    cout << '!' << ' ' << x << endl;
    exit(0);
}

int ask(int x) {
    cout << '?' << ' ' << x << endl;
    int ret;
    cin >> ret;
    return ret;
}
int n;
int L = 1;
int R = n;
int LST = 0;

void solve(int l, int r, int lst) {
    L = l;
    R = r;
    LST = lst;
    cout << l << ' ' << r << endl;
    if (l + 1 < r) {

    } else {
        return;
    }
    int mid = (l + r) >> 1;
    int x = ask(mid);
    if(x == lst) {
        answer(mid);
    }
    int y = ask(r);
    if(y == x) {
        answer(r);
    }
    if(x < y) {
        solve(l, mid + 1, y);
    }
    //0 1 1
    else {
        solve(mid - 1, r - 1, y);
    }
    return;
}

int main() {
    cin >> n;
    L = 1, R = n;
    solve(1, n, 0);
    if (ask(L) == LST) {
        answer(L);
    } else {
        answer(R);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3652kb

input:

3

output:

1 3
? 2

result:

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