QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65791 | #4884. Battleship: New Rules | japan022022# | RE | 2ms | 3320kb | C++20 | 1.5kb | 2022-12-03 17:17:59 | 2022-12-03 17:18:01 |
Judging History
answer
#include<iostream>
#include<cstdlib>
#include<cassert>
using namespace std;
bool ask(int x,int y)
{
cout<<"? "<<x<<" "<<y<<endl;
int r;cin>>r;
if(r==-1)exit(0);
return r==1;
}
void answer(int x,int y)
{
cout<<"! "<<x<<" "<<y<<endl;
int r;cin>>r;
if(r==-1)exit(0);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
int N;
cin>>N;
if(N%2==1)
{
answer(-1,-1);
continue;
}
int x=1,y=1;
while(N>=6)
{
int f1,f2,f3,f4;
//f1=!ask(x+1,y+1)&&!ask(x+1,y+N-4)&&!ask(x+N-4,y+N-4)&&!ask(x+N-4,y+1);
f1=!ask(x+1,y+N-4)&&!ask(x+N-4,y+N-4)&&!ask(x+N-4,y+1);
//f2=!ask(x+1,y+3)&&!ask(x+1,y+N-2)&&!ask(x+N-4,y+N-2)&&!ask(x+N-4,y+3);
f2=!ask(x+1,y+3)&&!ask(x+N-4,y+N-2)&&!ask(x+N-4,y+3);
//f3=!ask(x+3,y+1)&&!ask(x+3,y+N-4)&&!ask(x+N-2,y+N-4)&&!ask(x+N-2,y+1);
f3=!ask(x+3,y+1)&&!ask(x+3,y+N-4)&&!ask(x+N-2,y+N-4);
//f4=!ask(x+3,y+3)&&!ask(x+3,y+N-2)&&!ask(x+N-2,y+N-2)&&!ask(x+N-2,y+3);
f4=!ask(x+3,y+3)&&!ask(x+3,y+N-2)&&!ask(x+N-2,y+3);
if(f1&&f2&&f3&&f4)
{
}
else if(f1+f2+f3+f4==3)
{
if(!f1)x+=2,y+=2;
else if(!f2)x+=2;
else if(!f3)y+=2;
}
else if(f1+f2+f3+f4==1)
{
if(f1);
else if(f2)y+=2;
else if(f3)x+=2;
else x+=2,y+=2;
}
else if(f1+f2+f3+f4==2)
{
if(f1);
else if(f2)y+=2;
else if(f3)x+=2;
else x+=2,y+=2;
}
else assert(false);
N-=2;
}
answer(x+1,y+1);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3320kb
input:
2 3 1 4 1
output:
! -1 -1 ! 2 2
result:
ok max_C=0.00, avg_C=0.00 (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3224kb
input:
100 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 ...
output:
! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ! 2 2 ...
result:
ok max_C=0.00, avg_C=0.00 (100 test cases)
Test #3:
score: -100
Dangerous Syscalls
input:
100 10 0 0 0 0 0 0 0 0 0 0 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