QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73753#4884. Battleship: New RulesAppleblue17WA 2ms3304kbC++14734b2023-01-27 21:36:112023-01-27 21:36:11

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-27 21:36:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3304kb
  • [2023-01-27 21:36:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int T,n;

void solve(int l,int r,int L,int R,bool typ){
	if(l==r && L==R){
		if(typ) swap(l,L);
		cout<<"! "<<l-1<<" "<<L-1<<'\n';
		return ;
	}
	if(R-L<r-l){
		solve(L,R,l,r,typ^1);
		return ;
	}
	int MID=(L+R)>>1;
	int tot=0,lst=0;
	for(int i=l;i<r;i++){
		if(!typ) cout<<"? "<<i<<" "<<MID<<'\n';
		else cout<<"? "<<MID<<" "<<i<<'\n';
		int s; cin>>s;
		if(s || lst) tot++;
		lst=s;
	}
	if(lst) tot++;
	
	if(((r-l+1)*(MID-L+1)%2)^(tot%2)) solve(l,r,L,MID,typ);
	else solve(l,r,MID+1,R,typ);
}

int main(){
	cin>>T;
	while(T--){
		cin>>n;
		if(n & 1){
			cout<<"! -1 -1"<<'\n';
			continue;
		}
		solve(1,n+1,1,n+1,0);
		
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
1
4
-1

output:

! -1 -1
! -1 -1

result:

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