QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56097#4884. Battleship: New RulesSorting#WA 3ms3704kbC++1.8kb2022-10-16 23:10:522022-10-16 23:10:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-16 23:10:53]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3704kb
  • [2022-10-16 23:10:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned char uc;
typedef long long ll;
#define fi first
#define se second
int n;
char c[2001][2001];
char ask(int x,int y){
	cout << "? " << x << ' ' << y << endl;
	int z;cin >> z;
	if(z==1) return 'X';
	else return '.';
}
void solve(int xl,int xr,int yl,int yr){
	if(xr==xl+1 && yr==yl+1){
		cout << "! " << xl*2 << ' ' << yl*2 << '\n';
		return;
	}
	if(xr-xl>yr-yl){
		int xm=(xl+xr)/2;
		for(int i=xm*2-1; i<=xm*2 ;i++){
			for(int j=yl*2-1; j<=yr ;j++){
				if(c[i][j]=='?') c[i][j]=ask(i,j);
			}
		}
		for(int k=yl; k<=yr ;k++){
			if(c[xm*2-1][2*k-1]=='X' && c[xm*2-1][2*k]=='X'){
				solve(xm,xr,yl,yr);
				return;
			}
			if(c[xm*2][2*k-1]=='X' && c[xm*2][2*k]=='X'){
				solve(xl,xm,yl,yr);
				return;
			}
		}
		if(c[xm*2-1][2*yl]=='X' || c[xm*2-1][2*yr-1]){
			solve(xm,xr,yl,yr);
			return;
		}
		else if(c[xm*2][2*yl]=='X' || c[xm*2][2*yr-1]){
			solve(xl,xm,yl,yr);
			return;
		}
		else while(true);
	}
	else{
		int ym=(yl+yr)/2;
		for(int i=xl*2-1; i<=xr*2 ;i++){
			for(int j=ym*2-1; j<=ym ;j++){
				if(c[i][j]=='?') c[i][j]=ask(i,j);
			}
		}
		for(int k=xl; k<=xr ;k++){
			if(c[2*k-1][ym*2-1]=='X' && c[2*k][ym*2-1]=='X'){
				solve(xl,xr,ym,yr);
				return;
			}
			if(c[2*k-1][ym*2]=='X' && c[2*k][ym*2]=='X'){
				solve(xl,xr,yl,ym);
				return;
			}
		}
		if(c[2*xl][ym*2-1]=='X' || c[2*xr-1][ym*2-1]){
			solve(xl,xr,ym,yr);
			return;
		}
		else if(c[2*xl][ym*2]=='X' || c[2*xr-1][ym*2]){
			solve(xl,xr,yl,ym);
			return;
		}
		else while(true);
	}
}
void solve(){
	cin >> n;
	if(n%2==1){
		cout << "! -1 -1" << endl;
		return;
	}
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=n ;j++){
			c[i][j]='?';
		}
	}
	solve(1,n/2,1,n/2);
}
int main(){
	ios::sync_with_stdio(false);
	int t;cin >> t;while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3704kb

input:

2
3
1
4
-1

output:

! -1 -1
! -1 -1

result:

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