QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#65774 | #4884. Battleship: New Rules | japan022022# | RE | 7ms | 3292kb | C++20 | 1.5kb | 2022-12-03 16:46:22 | 2022-12-03 16:46:25 |
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)
{
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;
}
else assert(false);
}
assert(N==4);
answer(x+1,y+1);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3232kb
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: 7ms
memory: 3292kb
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 1 1 1 0 0 0 0
output:
? 1 8 ? 8 8 ? 8 1 ? 1 3 ? 8 10 ? 8 3 ? 3 1 ? 3 8 ? 10 8 ? 3 3 ? 3 10 ? 10 3 ? 3 6 ? 6 6 ? 6 3 ? 3 5 ? 5 3 ? 5 5