QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528284 | #6394. Turn on the Light | megumi# | WA | 1ms | 3684kb | C++14 | 1.3kb | 2024-08-23 12:27:31 | 2024-08-23 12:27:34 |
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 = 2, r, ans = 0, x, last = 0;
cin >> n, r = n;
cout << "? 1" << endl;
cin >> last;
if (last == 0) {
cout << "! 1" << endl;
return 0;
}
while (l <= r) {
int mid = (l + r) >> 1;
cout << "? " << mid << endl;
cin >> x;
if (x == last) {
cout << "! " << mid << endl;
return 0;
}
if (x == last - 1) {
last = x;
cout << "? " << l + 1 << endl;
cin >> x;
if (x == last) {
cout << "! " << l + 1 << endl;
return 0;
}
r = mid - 1;
l++;
} else {
last = x;
cout << "? " << mid + 1 << endl;
cin >> x;
if (x == last) {
cout << "! " << mid + 1 << endl;
return 0;
}
l = mid + 2;
}
last = x;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected