QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#684496 | #8937. Stage: Agausscrab | real_sigma_team# | TL | 0ms | 0kb | C++23 | 1.0kb | 2024-10-28 13:55:35 | 2024-10-28 13:55:38 |
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;
}
double phi = 2 / (sqrt(5) + 1);
int len = (r - l + 1) * phi;
int m1 = r - len;
int m2 = l + len;
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: 0
Time Limit Exceeded
input:
4 arcos 2 gausr 5 scrail 3 bei 3
output:
? 1 0 ? 1 1 ? 2 0 ? 2 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ? 3 0 ? 3 2 ...