QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65779 | #4884. Battleship: New Rules | japan022022# | RE | 2ms | 3412kb | C++20 | 1.5kb | 2022-12-03 16:49:08 | 2022-12-03 16:49:09 |
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,y)&&ask(x,y+N-3)&&ask(x+N-3,y+N-3)&&ask(x+N-3,y);
f1=ask(x,y+N-3)&&ask(x+N-3,y+N-3)&&ask(x+N-3,y);
//f2=ask(x,y+2)&&ask(x,y+N-1)&&ask(x+N-3,y+N-1)&&ask(x+N-3,y+2);
f2=ask(x,y+2)&&ask(x+N-3,y+N-1)&&ask(x+N-3,y+2);
//f3=ask(x+2,y)&&ask(x+2,y+N-3)&&ask(x+N-1,y+N-3)&&ask(x+N-1,y);
f3=ask(x+2,y)&&ask(x+2,y+N-3)&&ask(x+N-1,y+N-3);
//f4=ask(x+2,y+2)&&ask(x+2,y+N-1)&&ask(x+N-1,y+N-1)&&ask(x+N-1,y+2);
f4=ask(x+2,y+2)&&ask(x+2,y+N-1)&&ask(x+N-1,y+2);
if(f1&&f2&&f3&&f4)
{
N-=2;
/*
x+=2;
y+=2;
N-=4;
*/
}
else if(f1+f2+f3+f4==3)
{
if(!f1)x+=2,y+=2;
else if(!f2)x+=2;
else if(!f3)y+=2;
N-=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;
N-=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;
N-=2;
}
else assert(false);
}
assert(N==4);
answer(x+1,y+1);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3224kb
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: 3412kb
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 1 1 1 1 1 1 1 1 1 1 1 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