QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528264 | #6394. Turn on the Light | megumi# | WA | 1ms | 3684kb | C++14 | 932b | 2024-08-23 12:15:36 | 2024-08-23 12:15:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9')
f = (c == '-') ? -1 : 1, c = getchar();
while (c >= '0' && c <= '9')
x = x * 10 + c - 48, c = getchar();
return f * x;
}
signed main() {
int n, l = 1, r = n, ans = 0, x, last = 0;
cin >> n;
while (l <= r) {
cout << "? " << l << endl;
int y;
cin >> y;
if (y == last) {
cout << "! " << l << endl;
return 0;
}
last = y;
int mid = (l + r) >> 1;
cout << "? " << mid << endl;
cin >> x;
if (x == last) {
cout << "! " << mid << endl;
return 0;
}
if (x == last - 1)
r = mid - 1;
else
l = mid + 1;
last = x;
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3684kb
input:
3 1
output:
? 1 ? 16349
result:
wrong answer Integer parameter [name=x] equals to 16349, violates the range [1, 3]