QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73412#4884. Battleship: New Rulesaurelion_solWA 2ms3496kbC++14979b2023-01-25 10:05:342023-01-25 10:05:35

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:05:35]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3496kb
  • [2023-01-25 10:05:34]
  • 提交

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)