QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470407 | #6394. Turn on the Light | UESTC_OldEastWest# | WA | 1ms | 3684kb | C++17 | 761b | 2024-07-10 12:55:17 | 2024-07-10 12:55:17 |
Judging History
answer
#include <bits/stdc++.h>
using ll = long long;
void charming() {
int n; std::cin >> n;
auto send = [](int x) -> int {
std::cout << "? " << x << std::endl;
std::cout.flush();
int ret; std::cin >> ret;
return ret;
};
auto answer = [](int x) -> void {
std::cout << "! " << x << std::endl;
std::cout.flush();
};
int l = 1, r = n, k = 1, diff = 0;
while (l <= r) {
int mid = l + r >> 1;
int ret = send(mid);
if (ret == diff) {k = mid; break;}
else if (ret > diff) l = mid + 1;
else r = mid - 1;
diff = ret;
}
answer(k);
}
signed main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
charming();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3684kb
input:
10 1 2 3 4
output:
? 5 ? 8 ? 9 ? 10 ! 1
result:
wrong answer Wrong answer, more than 1 possible light!