QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#83782#4884. Battleship: New Rules_UMqwq_WA 2ms3544kbC++201.1kb2023-03-03 14:47:312023-03-03 14:47:32

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 14:47:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3544kb
  • [2023-03-03 14:47:31]
  • 提交

answer

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3544kb

input:

2
3
1
4
-1

output:

! -1 -1
! -1 -1

result:

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