QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#387314 | #6394. Turn on the Light | Dog_E# | WA | 0ms | 3668kb | C++20 | 958b | 2024-04-12 13:10:59 | 2024-04-12 13:11:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
int ask(int x) {
cout << "? " << x << endl;
int res;
cin >> res;
return res;
}
void print(int x) {
cout << "! " << x << endl;
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
int l = 1, r = n;
int last, now;
last = ask(1);
if (last == 0) {
print(1);
return 0;
}
int mid = l + r >> 1;
now = ask(mid);
if (now == last) {
print(mid);
return 0;
}
if (now == 0) {
r = mid - 1;
last = now;
now = ask(n);
} else {
l = mid + 1;
last = now;
}
while (l < r) {
mid = l + r >> 1;
last = now;
now = ask(mid);
if (now == last) {
print(mid);
return 0;
}
}
cout << l << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3668kb
input:
3 1 2
output:
? 1 ? 2 3
result:
wrong answer Token parameter [name=type] equals to "3", doesn't correspond to pattern "?|!"