QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#684447 | #8939. Permutation | real_sigma_team# | WA | 145ms | 3688kb | C++23 | 1021b | 2024-10-28 13:33:23 | 2024-10-28 13:33:23 |
Judging History
answer
#include<bits/stdc++.h>
int main() {
// std::cin.tie(nullptr)->sync_with_stdio(false);
int tests;
std::cin >> tests;
while (tests--) {
int n;
std::cin >> n;
auto rec = [&](auto rec, int l, int r, int p) -> void {
if (l == r) {
std::cout << "! " << l << std::endl;
return;
}
if (p == -1) {
std::cout << "? " << l << ' ' << r << std::endl;
std::cin >> p;
}
if (r - l == 1) {
if (l == p) std::cout << "! " << r << std::endl;
else std::cout << "! " << l << std::endl;
return;
}
int m1 = (2 * l + r) / 3;
int m2 = (l + r * 2) / 3;
if (p > m1) {
std::cout << "? " << m1 + 1 << ' ' << r << std::endl;
int shq;
std::cin >> shq;
if (shq == p) rec(rec, m1 + 1, r, p);
else rec(rec, l, m1, -1);
} else {
std::cout << "? " << l << ' ' << m2 << std::endl;
int shq;
std::cin >> shq;
if (shq == p) rec(rec, l, m2, p);
else rec(rec, m2 + 1, r, -1);
}
};
rec(rec, 1, n, -1);
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
input:
3 5 3 3 3 6 6 3 1 4 3 3
output:
? 1 5 ? 3 5 ? 3 4 ! 4 ? 1 6 ? 3 6 ? 1 2 ! 2 ? 1 4 ? 3 4 ! 4
result:
ok Correct (3 test cases)
Test #2:
score: 0
Accepted
time: 66ms
memory: 3636kb
input:
10000 10 2 2 2 3 5 10 10 10 7 5 10 5 5 5 5 6 10 4 4 6 2 2 10 10 6 3 4 2 10 3 3 3 5 2 10 1 5 9 10 10 1 1 3 6 10 2 4 9 9 10 3 3 3 3 3 10 4 7 8 9 10 8 7 1 1 2 10 4 1 9 9 10 7 7 8 6 10 5 5 7 10 10 8 8 8 9 10 2 2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? 1 9 ? 1 6 ? 1 4 ? 1 3 ! 4 ? 1 16 ? 1 11 ? 1 7...
result:
ok Correct (10000 test cases)
Test #4:
score: 0
Accepted
time: 145ms
memory: 3616kb
input:
10000 47 23 31 11 9 2 2 1 14 8 8 8 8 8 9 25 6 6 4 13 13 13 13 7 4 4 4 4 9 2 2 2 2 3 27 27 27 27 27 24 21 21 21 7 7 6 5 5 5 43 41 21 7 8 5 4 1 22 6 14 20 20 21 34 29 29 25 17 20 14 14 42 20 20 20 20 27 17 17 17 47 21 21 21 21 21 20 19 19 41 25 25 25 30 36 36 36 36 19 17 17 16 9 10 21 14 14 19 10 10 1...
output:
? 1 47 ? 17 47 ? 1 16 ? 7 16 ? 1 6 ? 1 4 ? 1 3 ! 4 ? 1 14 ? 6 14 ? 6 11 ? 8 11 ? 8 10 ? 8 9 ! 10 ? 1 25 ? 1 17 ? 1 11 ? 12 17 ? 12 15 ? 12 14 ? 13 14 ! 14 ? 1 7 ? 4 7 ? 4 6 ? 4 5 ! 5 ? 1 9 ? 1 6 ? 1 4 ? 1 3 ? 2 3 ! 1 ? 1 27 ? 10 27 ? 16 27 ? 20 27 ? 23 27 ? 20 22 ? 21 22 ! 22 ? 1 21 ? 1 14 ? 6 14 ? ...
result:
ok Correct (10000 test cases)
Test #5:
score: -100
Wrong Answer
time: 12ms
memory: 3684kb
input:
10000 100 47 47 47 61 71 71 71 71 72 69 9 2 2 2 2 2 53 46 35 6 6 6 6 6 7 33 3 16 31 31 31 30 82 60 29 4 8 23 23 23 23 24 88 39 39 39 51 59 59 59 61 57 71 24 29 59 59 59 59 59 60 92 52 52 45 88 88 88 88 88 89 24 11 20 5 5 5 6 66 51 51 51 66 45 43 39 40 92 43 50 20 20 25 12 13 17 48 1 1 1 1 1 5 9 9 85...
output:
? 1 100 ? 35 100 ? 35 78 ? 35 63 ? 64 78 ? 69 78 ? 69 75 ? 69 73 ? 71 73 ? 69 70 ! 70 ? 1 9 ? 1 6 ? 1 4 ? 1 3 ? 2 3 ! 3 ? 1 53 ? 19 53 ? 1 18 ? 1 12 ? 5 12 ? 5 9 ? 5 7 ? 6 7 ! 5 ? 1 33 ? 1 22 ? 23 33 ? 27 33 ? 30 33 ? 30 32 ! 33 ? 1 82 ? 29 82 ? 1 28 ? 1 19 ? 20 28 ? 23 28 ? 23 26 ? 23 25 ? 23 24 ! ...
result:
wrong answer Too many queries , n = 98 , now_q 11 (test case 1124)