QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#542880#8939. Permutationucup-team1766#WA 3ms3708kbC++23909b2024-09-01 06:47:472024-09-01 06:47:48

Judging History

This is the latest submission verdict.

  • [2024-09-01 06:47:48]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 3708kb
  • [2024-09-01 06:47:47]
  • Submitted

answer

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

const long double d = 1/2.62L;

void run() {
	int n; cin >> n;

	int l = 1, r = n;
	int mx = -1;
	while (l+1 < r) {
		if (mx == -1) {
			cout << "? " << l << " " << r << endl;
			cin >> mx;
		}
		if (mx <= l + (r - l) / 2) {
			int m = r - int((r - l + 1) * d);
			if (m == r) m--;
			cout << "? " << l << " " << m << endl;
			int x; cin >> x;
			if (x == mx) {
				r = m;
			} else {
				l = m+1;
				mx = -1;
			}
		} else {
			int m = l + int((r - l + 1) * d);
			if (m == l) m++;
			cout << "? " << m << " " << r << endl;
			int x; cin >> x;
			if (x == mx) {
				l = m;
			} else {
				r = m-1;
				mx = -1;
			}
		}
	}
	if (l+1 == r) {
		if (mx == -1) {
			cout << "? " << l << " " << r << endl;
			cin >> mx;
		}
		if (mx == l) l = r;
	}

	cout << "! " << l << endl;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int t; cin >> t; while (t--) run();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

3
5
3
3
3
2
6
6
3
1
4
3
3
2

output:

? 1 5
? 1 4
? 2 4
? 2 3
! 4
? 1 6
? 3 6
? 1 2
! 2
? 1 4
? 2 4
? 2 3
! 4

result:

ok Correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3708kb

input:

10000
10
2
2
2
2
3
10
10
10
10
7
10
5
5
5
4
10
4
4
4
4
4

output:

? 1 10
? 1 7
? 1 5
? 1 4
? 1 3
! 4
? 1 10
? 4 10
? 6 10
? 7 10
! 6
? 1 10
? 1 7
? 3 7
? 3 6
! 7
? 1 10
? 1 7
? 1 5
? 2 5
? 3 5
? 3 4

result:

wrong answer Too many queries , n = 10 , now_q 6 (test case 4)