QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599366#8939. PermutationzookeeperCompile Error//C++141.3kb2024-09-29 03:50:032024-09-29 03:50:05

Judging History

This is the latest submission verdict.

  • [2024-09-29 03:50:05]
  • Judged
  • [2024-09-29 03:50:03]
  • Submitted

answer

#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int solve() {
    int N;
    cin >> N;
    int L = 1, R = N, S = -1;
    while (true) {
        if (L == R) return L;
        if (S == -1) {
            cout << "? " << L << ' ' << R << endl;
            cin >> S;
            continue;
        }
        if (L + 1 == R) {
            return S == L ? R : L;
        }
        if (S - L < R - S) {
            // query right
            int mid = (S + R) / 2;
            cout << "? " << S << ' ' << mid << endl;
            int SS;
            cin >> SS;
            if (SS == S) {
                L = S;
                R = mid;
                if (L + 1 == R) {
                    return R;
                }
                continue;
            }
            L = mid + 1;
            S = -1;
            continue;
        } else {
            // query left
            int mid = (L + S) / 2;
            cout << "? " << mid << ' ' << S << endl;
            int SS;
            cin >> SS;
            if (SS == S) {
                R = S;
                L = mid;
                if (L + 1 == R) {
                    return L;
                }
                continue;
            }
            R = mid - 1;
            S = -1;
        }
    }

Details

answer.code: In function ‘int solve()’:
answer.code:53:6: error: expected ‘}’ at end of input
   53 |     }
      |      ^
answer.code:5:13: note: to match this ‘{’
    5 | int solve() {
      |             ^