QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73412 | #4884. Battleship: New Rules | aurelion_sol | WA | 2ms | 3496kb | C++14 | 979b | 2023-01-25 10:05:34 | 2023-01-25 10:05:35 |
Judging History
answer
#include<bits/stdc++.h>
#define rp(i,a,b) for(int i=a,_=b;i<=_;++i)
#define pr(i,a,b) for(int i=a,_=b;i>=_;--i)
using namespace std;
int T,n;
int query(int x,int y){
printf("? %d %d\n",x,y),fflush(stdout);
int z;scanf("%d",&z);return z;
}
void put(int x,int y){
if(x<1||x>=n-1||y<1||y>=n-1)x=-1,y=-1;
printf("! %d %d\n",x,y),fflush(stdout);
}
void solve(int u,int d,int l,int r){
if(u==d&&l==r){
put(u-1,l-1);
return;
}
if(d-u>=r-l){
int mid=(u+d)/2;
int A=(d-mid)*(r-l+1),L=0;
rp(i,l,r-1){
int x=query(mid,i);
A-=x|L,L=x;
}
if(A&1)solve(mid+1,d,l,r);
else solve(u,mid,l,r);
}else{
int mid=(l+r)/2;
int A=(r-mid)*(d-u+1),L=0;
rp(i,u,d-1){
int x=query(i,mid);
A-=x|L,L=x;
}
if(A&1)solve(u,d,mid+1,r);
else solve(u,d,l,mid);
}
}
void work(){
scanf("%d",&n);
++n;
if(~n&1){
put(-1,-1);
}else{
solve(1,n,1,n);
}
}
int main(){
scanf("%d",&T);
while(T--)work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3496kb
input:
2 3 1 4 -1
output:
! -1 -1 ! -1 -1
result:
wrong output format Unexpected end of file - int32 expected (test case 2)