QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73765 | #4884. Battleship: New Rules | Appleblue17 | WA | 8ms | 3496kb | C++14 | 1.2kb | 2023-01-27 22:13:51 | 2023-01-27 22:13:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int T,n;
int f[N][N];
int cal(int x,int y){
if(x>n || y>n) return 0;
if(f[x][y]!=-1) return f[x][y];
cout<<"? "<<x<<" "<<y<<'\n';
cin>>f[x][y];
return f[x][y];
}
int calc(int l,int r,int L,int R){
int tot=(r-l+1)*(R-L+1)%2,lst;
for(int i=l-1;i<=r;i++) cal(i,R);
lst=cal(l-1,R);
for(int i=l;i<=r;i++){
int s=cal(i,R);
if(s || lst) tot^=1;
lst=s;
}
for(int i=L-1;i<=R;i++) cal(r,i);
lst=cal(r,L-1);
for(int i=L;i<=R;i++){
int s=cal(r,i);
if(s || lst) tot^=1;
lst=s;
}
if(cal(r,R)) tot^=1;
return tot;
}
void solve(int l,int r,int L,int R){
if(l==r && L==R){
cout<<"! "<<l-1<<" "<<L-1<<'\n';
int s; cin>>s;
return ;
}
if(R-L>r-l){
int MID=(L+R)>>1;
if(calc(l,r,L,MID)) solve(l,r,L,MID);
else solve(l,r,MID+1,R);
}
else{
int mid=(l+r)>>1;
if(calc(l,mid,L,R)) solve(l,mid,L,R);
else solve(mid+1,r,L,R);
}
}
int main(){
cin>>T;
while(T--){
cin>>n;
for(int i=1;i<=n+1;i++)
for(int j=1;j<=n+1;j++)
f[i][j]=-1;
if(n & 1){
cout<<"! -1 -1"<<'\n';
int s; cin>>s;
continue;
}
solve(1,n+1,1,n+1);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3496kb
input:
2 3 1 4 1 0 0 0 0 0 0 0 1
output:
! -1 -1 ? 3 1 ? 3 2 ? 3 3 ? 3 4 ? 1 3 ? 2 3 ? 2 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