QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73413#4884. Battleship: New Rulesaurelion_solWA 2ms3540kbC++141023b2023-01-25 10:07:492023-01-25 10:07:50

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-25 10:07:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3540kb
  • [2023-01-25 10:07:49]
  • 提交

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);
	int z;scanf("%d",&z);
	if(z==-1)exit(0);
}
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: 100
Accepted
time: 2ms
memory: 3540kb

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 1
? 2 2
! 2 2

result:

ok max_C=2.00, avg_C=1.00 (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3476kb

input:

100
4
1
0
0
0
0
0
0
0
1
4
1
0
0
0
0
0
0
0
1
4
0
0
0
1
0
1
-1

output:

? 3 1
? 3 2
? 3 3
? 3 4
? 1 3
? 2 3
? 2 1
? 2 2
! 2 2
? 3 1
? 3 2
? 3 3
? 3 4
? 1 3
? 2 3
? 2 1
? 2 2
! 2 2
? 3 1
? 3 2
? 3 3
? 3 4
? 4 3
? 4 2
! -1 -1

result:

wrong output format Unexpected end of file - int32 expected (test case 3)