QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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!