QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395409 | #8239. Mysterious Tree | Qian# | WA | 1ms | 3948kb | C++14 | 877b | 2024-04-21 14:17:09 | 2024-04-21 14:17:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n;
bool ask(int x,int y){
printf("? %d %d\n",x+1,y+1);
fflush(stdout);
int p;
scanf("%d",&p);
fflush(stdout);
return p;
}
int main(){
int T;scanf("%d",&T);
while(T--){
fflush(stdout);
int n;scanf("%d",&n);
fflush(stdout);
bool flag=0;
for(int i=0;i<n;i+=2)
if(ask(i,i+1)){
flag=1;
if(ask(i,(i+2)%n)){
if(ask(i,(i+3)%n)){
printf("! 2\n");
}
else printf("! 1\n");
}
else if(ask(i+1,(i+2)%n)){
if(ask(i+1,(i+3)%n)){
printf("! 2\n");
}
else printf("! 1\n");
}
else printf("! 1\n");
break;
}
if(flag)continue;
if(n&1){
if(ask(n,1)){
if(ask(n,2)){
printf("! 2\n");
}
else printf("! 1\n");
}
else printf("! 1\n");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3948kb
input:
2 4 1 0 1 0 4 0 1 1 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 3 2 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3896kb
input:
87 13 0 0 0 0 0 1 0 1 1 15 0 0 0 0 0 0 1 1 1 7 0 0 0
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 13 ? 12 13 ? 12 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 15 ? 13 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8
result:
wrong answer Integer 8 violates the range [1, 7] (test case 3)