QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#65828 | #4884. Battleship: New Rules | japan022022# | WA | 6ms | 3368kb | C++20 | 2.7kb | 2022-12-03 18:58:34 | 2022-12-03 18:58:36 |
Judging History
answer
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<algorithm>
#include<vector>
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 A1=0;//ask(x+1,y+1)
int A2=ask(x+1,y+N-4);
int A3=ask(x+N-4,y+N-4);
int A4=ask(x+N-4,y+1);
int B1=ask(x+1,y+3);
int B2=0;//ask(x+1,y+N-2)
int B3=ask(x+N-4,y+N-2);
int B4=ask(x+N-4,y+3);
int C1=ask(x+3,y+3);
int C2=ask(x+3,y+N-2);
int C3=0;//ask(x+N-2,y+N-2)
int C4=ask(x+N-2,y+3);
int D1=ask(x+3,y+1);
int D2=ask(x+3,y+N-4);
int D3=ask(x+N-2,y+N-4);
int D4=0;//ask(x+N-2,y+1)
int fA=A1+A2+A3+A4==0;
int fB=B1+B2+B3+B4==0;
int fC=C1+C2+C3+C4==0;
int fD=D1+D2+D3+D4==0;
if(fA+fB+fC+fD==3)
{
if(!fA)x+=2,y+=2;
else if(!fB)x+=2;
else if(!fC);
else y+=2;
}
else if(fA+fB+fC+fD==1)
{
if(fA);
else if(fB)y+=2;
else if(fC)x+=2,y+=2;
else x+=2;
}
else
{
vector<pair<int,int> >T;
T.push_back(make_pair(A1+B1+C1+D1,1));
T.push_back(make_pair(A2+B2+C2+D2,2));
T.push_back(make_pair(A3+B3+C3+D3,3));
T.push_back(make_pair(A4+B4+C4+D4,4));
sort(T.begin(),T.end());
int id=T.back().second;
if(id==1);
else if(id==2)y+=2;
else if(id==3)x+=2,y+=2;
else x+=2;
}
/*
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);
}
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 3284kb
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: 6ms
memory: 3128kb
input:
100 4 1 4 1 4 1 4 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