QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73414#4884. Battleship: New Rulesaurelion_solWA 7ms3712kbC++141.0kb2023-01-25 10:11:102023-01-25 10:11:12

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:11:12]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3712kb
  • [2023-01-25 10:11:10]
  • 提交

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;
		}
		A-=L;
		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;
		}
		A-=L;
		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: 3ms
memory: 3712kb

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: 0
Accepted
time: 7ms
memory: 3552kb

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
1
0
1
0
1
4
0
0
0
1
1
0
1
0
1
4
1
0
0
0
0
0
0
0
1
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
1
0
1
0
1
4
0
0
0
1
1
0
1
0
1
4
0
0
0
1
1
0
1
0
1
4
0
0
0
1
1
0
1
0
1
4
1
0
0
0
0
0
0
0
1
4
0
0
0
1
1
0
1
0
1
4
1
0
0
0
0
0
0
0
1
4
1
0
0
0
0
0
0
...

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

result:

ok max_C=2.00, avg_C=2.00 (100 test cases)

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3524kb

input:

100
10
1
1
0
1
0
1
0
1
0
1
1
0
1
1
1
1
0
1
1
0
0
0
1
0
-1

output:

? 6 1
? 6 2
? 6 3
? 6 4
? 6 5
? 6 6
? 6 7
? 6 8
? 6 9
? 6 10
? 1 6
? 2 6
? 3 6
? 4 6
? 5 6
? 3 1
? 3 2
? 3 3
? 3 4
? 3 5
? 4 3
? 5 3
? 5 4
? 5 5
! 5 5

result:

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