QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#83791#4884. Battleship: New Rules_UMqwq_WA 1ms3784kbC++201.3kb2023-03-03 15:14:422023-03-03 15:14:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-03 15:14:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3784kb
  • [2023-03-03 15:14:42]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define MAXN 1010
using namespace std;
int T,n,a[MAXN][MAXN];
int query(int x,int y){
	printf("? %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w;
}
bool check(int x,int y){
	printf("! %lld %lld\n",x,y);fflush(stdout);
	int w;scanf("%lld",&w);return w==1;
}
void solve(int xl,int xr,int yl,int yr){//cerr<<"solve:"<<xl<<' '<<xr<<' '<<yl<<' '<<yr<<endl;
	if(xl==xr&&yl==yr){assert(check(xl-1,yl-1));return;}
	if(xr-xl>yr-yl){
		int mid=(xl+xr)>>1;
		for(int i=yl;i<yr;i++){
			int now=query(mid,i);
			a[mid][i]|=now;a[mid+1][i]|=now;
			a[mid][i+1]|=now;a[mid+1][i+1]|=now;
		}
		int ls=0;
		for(int i=xl;i<=mid;i++)
			for(int j=yl;j<=yr;j++)ls^=(!a[i][j]);
		if(ls)solve(xl,mid,yl,yr);
		else solve(mid+1,xr,yl,yr);
	}else{
		int mid=(yl+yr)>>1;
		for(int i=xl;i<xr;i++){
			int now=query(i,mid);
			a[i][mid]|=now;a[i+1][mid]|=now;
			a[i][mid+1]|=now;a[i+1][mid+1]|=now;
		}
		int ls=0;
		for(int i=xl;i<=xr;i++)
			for(int j=yl;j<=mid;j++)ls^=a[i][j];
		if(ls)solve(xl,xr,yl,mid);
		else solve(xl,xr,mid+1,yr);
	}
}
signed main(){
	scanf("%lld",&T);
	while(T--){
		scanf("%lld",&n);
		for(int i=1;i<=n+1;i++)
			for(int j=1;j<=n+1;j++)a[i][j]=0;
		if(n&1){assert(check(-1,-1));continue;}
		solve(1,n+1,1,n+1);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3784kb

input:

2
3
1
4
0
0
0
1
0
1

output:

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

result:

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