QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402273 | #6394. Turn on the Light | iwew# | WA | 0ms | 3584kb | C++20 | 759b | 2024-04-30 10:42:55 | 2024-04-30 10:42:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int l = 1, r = n, lstd = 0;
auto ask = [&](int mid) -> int {
cout << "? " << mid << endl;
int d;
cin >> d;
return d;
};
int ans = -1;
while(l < r) {
int mid = (l + r) >> 1;
auto curd = ask(mid);
if(curd - lstd == 0) {
ans = mid;
break;
} else if(curd - lstd == 1) {
l = mid + 1;
} else {
r = mid - 1;
}
lstd = curd;
}
if(ans == -1) ans = l;
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
3 1
output:
? 2 3
result:
wrong answer Token parameter [name=type] equals to "3", doesn't correspond to pattern "?|!"