QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574743#6394. Turn on the LightGammaRaysCompile Error//C++23972b2024-09-19 00:13:232024-09-19 00:13:29

Judging History

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

  • [2024-09-19 00:13:29]
  • 评测
  • [2024-09-19 00:13:23]
  • 提交

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;
    if (l + 1 < r) {

    } else {
        return;
    }
    int x = ask(r);
    if(x == lst) {
        answer(r);
    }
    r --;
    int mid = (l + r) >> 1;
    int y = ask(mid);
    if(y == x) {
        answer(mid);
    }
    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);
    cout << L << ' ' << R << endl;
    if (ask(L) == LST) {
        LST = answer(L);
    } else if (ask(R) == LST){
        answer(R);
    }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:55:21: error: void value not ignored as it ought to be
   55 |         LST = answer(L);
      |               ~~~~~~^~~