QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#138368 | #6394. Turn on the Light | Schi2oid | WA | 1ms | 3520kb | C++14 | 939b | 2023-08-11 16:40:51 | 2023-08-11 16:40:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int ask(int x){
int ret;
cout<<"? x"<<endl;
cin>>ret;
return ret;
}
int id[2][2000005];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++) id[0][i]=i;
bool op=0;
int bef=0;
while(n>4){
int p1=n/4,p2=n-n/4;
int x=ask(id[op][p1]);
if(x==bef){
cout<<"! p1";
return 0;
}
int y=ask(id[op][p2]);
if(y==x){
cout<<"! p2";
return 0;
}
int delta=y-bef;
op^=1;
if(delta==0){
n=p2-p1;
int cnt=0;
for(int i=p1+1;i<=p2;i++){
id[op][++cnt]=id[op^1][i];
}
}
else{
n=n-p2+p1-1;
int cnt=0;
for(int i=1;i<p1;i++){
id[op][++cnt]=id[op^1][i];
}
for(int i=p2+1;i<=n;i++){
id[op][++cnt]=id[op^1][i];
}
}
bef=y;
}
for(int i=1;i<=n;i++){
int x=ask(id[op][i]);
if(x==bef){
cout<<"! "<<id[op][i];
return 0;
}
bef=x;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3520kb
input:
3
output:
? x
result:
wrong answer format Expected integer, but "x" found