QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105558 | #6394. Turn on the Light | woyouxiangbaile# | WA | 2ms | 3496kb | C++14 | 1.4kb | 2023-05-14 13:15:48 | 2023-05-14 13:15:50 |
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, latp = 1;
bool visi[_maxn];
int quer(int at) {
putchar('?'), putchar(' '), uwit(at), putchar('\n'), fflush(stdout), visi[at] = 1;
return ured();
}
int main() {
n = ured(), efle = 1, efri = n;
while(efle <= efri) {
efmi = efle + efri >> 1;
if((lans = quer(efmi)) == tans) {
putchar('!'), putchar(' '), uwit(efmi), putchar('\n'), fflush(stdout);
return 0;
}
while(visi[latp]) {
++latp;
}
if((rans = quer(latp)) == lans) {
putchar('!'), putchar(' '), uwit(latp), putchar('\n'), fflush(stdout);
return 0;
}
if(lans == rans) {
if(latp < efmi) {
efle = latp + 1, efri = efmi - 1;
} else {
efle = efmi + 1, efri = latp - 1;
}
} else {
efle = efmi + 1;
}
tans = rans;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3328kb
input:
3 1 2 2
output:
? 2 ? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3336kb
input:
10 1 2 3 4 5 6 6
output:
? 5 ? 1 ? 8 ? 2 ? 9 ? 3 ? 10 ! 10
result:
ok Correct position at 10
Test #3:
score: 0
Accepted
time: 0ms
memory: 3264kb
input:
9 1 2 3 4 5 6 6
output:
? 5 ? 1 ? 7 ? 2 ? 8 ? 3 ? 9 ! 9
result:
ok Correct position at 9
Test #4:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
8 1 2 3 4 5 6 6
output:
? 4 ? 1 ? 6 ? 2 ? 7 ? 3 ? 8 ! 8
result:
ok Correct position at 8
Test #5:
score: 0
Accepted
time: 2ms
memory: 3332kb
input:
7 1 2 3 4 4
output:
? 4 ? 1 ? 6 ? 2 ? 7 ! 7
result:
ok Correct position at 7
Test #6:
score: 0
Accepted
time: 2ms
memory: 3260kb
input:
6 1 2 3 4 4
output:
? 3 ? 1 ? 5 ? 2 ? 6 ! 6
result:
ok Correct position at 6
Test #7:
score: 0
Accepted
time: 1ms
memory: 3328kb
input:
5 1 2 3 4 4
output:
? 3 ? 1 ? 4 ? 2 ? 5 ! 5
result:
ok Correct position at 5
Test #8:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
4 1 2 3 3
output:
? 2 ? 1 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 1ms
memory: 3444kb
input:
3 1 1
output:
? 2 ? 1 ! 1
result:
ok Correct position at 1
Test #10:
score: 0
Accepted
time: 2ms
memory: 3328kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1 0
output:
? 1 ! 1
result:
ok Correct position at 1
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 3304kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 31 32 31 32 31 32 31 32
output:
? 500000 ? 1 ? 750000 ? 2 ? 875000 ? 3 ? 937500 ? 4 ? 968750 ? 5 ? 984375 ? 6 ? 992188 ? 7 ? 996094 ? 8 ? 998047 ? 9 ? 999024 ? 10 ? 999512 ? 11 ? 999756 ? 12 ? 999878 ? 13 ? 999939 ? 14 ? 999970 ? 15 ? 999985 ? 16 ? 999993 ? 17 ? 999997 ? 18 ? 999999 ? 19 ? 1000000 ? 20
result:
wrong answer format Unexpected end of file - token expected