QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#858707#8939. Permutationlichenyu_acWA 0ms3456kbC++14776b2025-01-16 20:53:272025-01-16 20:53:37

Judging History

This is the latest submission verdict.

  • [2025-01-16 20:53:37]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3456kb
  • [2025-01-16 20:53:27]
  • Submitted

answer

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

int ask(int l, int r) {
	if (l == r) return 0;
	cout << "? " << l << " " << r << endl;
	int ret; cin >> ret;
	return ret;
}

int n;

int solve(int l, int r, int t) {
	if (l == r) return l;
	if (r - l + 1 == 2) {
		if (t == r) return l;
		else return r;
	}
	int mid = l + (r - l) * 0.618;
	if (t <= mid) {
		if (ask(l, mid) == t) return solve(l, mid, t);
		else return solve(mid + 1, r, ask(mid + 1, r));
	} else {
		mid = l + (r - l) * 0.382;
		if (ask(mid + 1, r) == t) return solve(mid + 1, r, t);
		else return solve(l, mid, ask(l, mid));
	}
}

void solve() {
	cin >> n;
	cout << "! " << solve(1, n, ask(1, n)) << endl;
}

int main() {
	int T; cin >> T;
	while (T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5

output:

! ? 1 5

result:

wrong answer format  Expected integer, but "?" found (test case 1)