QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56099#4884. Battleship: New RulesSorting#WA 13ms3696kbC++1.9kb2022-10-16 23:13:162022-10-16 23:13:19

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:13:19]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3696kb
  • [2022-10-16 23:13:16]
  • 提交

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 << endl;
		int res;cin >> res;
		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;
		int res;cin >> res;
		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();
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3576kb

input:

2
3
1
4
1

output:

! -1 -1
! 2 2

result:

ok max_C=0.00, avg_C=0.00 (2 test cases)

Test #2:

score: 0
Accepted
time: 13ms
memory: 3612kb

input:

100
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
...

output:

! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
! 2 2
...

result:

ok max_C=0.00, avg_C=0.00 (100 test cases)

Test #3:

score: -100
Wrong Answer
time: 10ms
memory: 3696kb

input:

100
10
0
0
-1

output:

? 5 5
? 6 5
! 8 8

result:

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