QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#542880 | #8939. Permutation | ucup-team1766# | WA | 3ms | 3708kb | C++23 | 909b | 2024-09-01 06:47:47 | 2024-09-01 06:47:48 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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)