QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#104894 | #6394. Turn on the Light | ckiseki# | WA | 2ms | 3800kb | C++14 | 1.3kb | 2023-05-12 12:33:00 | 2023-05-12 12:33:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
int ask(int x) {
printf("? %d\n", x);
fflush(stdout);
int y;
scanf("%d", &y);
return y;
}
int main() {
int n;
scanf("%d", &n);
if (ask(1) == 0) {
printf("! 1\n");
return 0;
}
int L_R = 1;
int L = 1, R = n + 1;
while (R - L > 1) {
int M = (L + R) >> 1;
int v = ask(M);
if (v == L_R - 1) {
--L_R;
R = M;
} else if (v == L_R) {
printf("! %d\n", M);
break;
} else {
++L_R;
L = M;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3800kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3788kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected