QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105560 | #6394. Turn on the Light | woyouxiangbaile# | WA | 4ms | 3436kb | C++14 | 1.4kb | 2023-05-14 13:21:58 | 2023-05-14 13:22:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
#define dep(i, u, d) for(int i = u; i >= d; --i)
#define cep(n) while(n--)
#define gep(i, a) for(int i = firs[a]; i; i = neig[i])
int ured() {
int re = 0;
char ch;
do {
ch = getchar();
} while('9' < ch || ch < '0');
do {
re = re * 10 + (ch ^ '0');
} while('0' <= (ch = getchar()) && ch <= '9');
return re;
}
void uwit(int da) {
int ch[21], cn = 0;
do {
ch[++cn] = da - da / 10 * 10;
} while(da /= 10);
do {
putchar('0' ^ ch[cn]);
} while(--cn);
}
const int _maxn = 1000011;
int n, efle, efri, efmi, efan, lans, rans, tans, matp;
vector<int> rest, cpys;
int quer(int at) {
putchar('?'), putchar(' '), uwit(at), putchar('\n'), fflush(stdout);
return ured();
}
int main() {
n = ured();
rep(i, 1, n) {
rest . push_back(i);
}
while(rest . size()) {
if((lans = quer(rest[0])) == tans) {
putchar('!'), putchar(' '), uwit(rest[0]), putchar('\n'), fflush(stdout);
return 0;
}
if((rans = quer(rest[matp = rest . size() >> 1])) == lans) {
putchar('!'), putchar(' '), uwit(rest[0]), putchar('\n'), fflush(stdout);
return 0;
}
cpys = rest, rest . clear();
if(rans == tans) {
rep(i, 1, matp - 1) {
rest . push_back(cpys[i]);
}
} else {
rep(i, matp + 1, cpys . size() - 1) {
rest . push_back(cpys[i]);
}
}
tans = rans;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3308kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 4ms
memory: 3260kb
input:
10 1 0 1 0 0
output:
? 1 ? 6 ? 2 ? 4 ? 3 ! 3
result:
ok Correct position at 3
Test #3:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
9 1 2 3 2 2
output:
? 1 ? 5 ? 6 ? 8 ? 7 ! 7
result:
ok Correct position at 7
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 3268kb
input:
8 1 0 1 1
output:
? 1 ? 5 ? 2 ? 3 ! 2
result:
wrong answer Wrong favorite light!