QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77288#4884. Battleship: New RuleshuzhaoyangWA 119ms7696kbC++141.2kb2023-02-13 22:31:132023-02-13 22:33:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-13 22:33:46]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:7696kb
  • [2023-02-13 22:31:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int t,n,vis[N][N];
void write(int x,int y){
	printf("! %d %d\n",x,y);
	fflush(stdout);
	scanf("%*d");
}
int query(int x,int y){
	if ((x<1)||(y<1)||(x>=n)||(y>=n))return 0;
	if (vis[x][y]<0){
		printf("? %d %d\n",x,y);
		fflush(stdout);
		scanf("%d",&vis[x][y]);
	}
	return vis[x][y];
}
bool check(int x1,int x2,int y1,int y2){
	int s=(x2-x1+1&1)*(y2-y1+1&1);
	for(int i=y1;i<=y2;i++){
		s^=(query(x1-1,i)|query(x1-1,i-1));
		s^=(query(x2,i)|query(x2,i-1));
	}
	for(int i=x1;i<=x2;i++){
		s^=(query(i,y1-1)|query(i-1,y1-1));
		s^=(query(i,y2)|query(i-1,y2));
	}
	return s;
}
void solve(int x1,int x2,int y1,int y2){
	if ((x1==x2)&&(y1==y2)){
		if ((x1==1)||(x1==n)||(y1==1)||(y1==n))write(-1,-1);
		else write(x1-1,y1-1);
		return;
	}
	if (x2-x1>y2-y1){
		int mid=(x1+x2>>1);
		if (check(x1,mid,y1,y2))solve(x1,mid,y1,y2);
		else solve(mid+1,x2,y1,y2);
	}
	else{
		int mid=(y1+y2>>1);
		if (check(x1,x2,y1,mid))solve(x1,x2,y1,mid);
		else solve(x1,x2,mid+1,y2);
	}
}
int main(){
	scanf("%d",&t);
	while (t--){
		scanf("%d",&n);
		n++;
		memset(vis,-1,sizeof(vis));
		if ((n<5)||(n&1^1))write(-1,-1);
		else solve(1,n,1,n);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 7488kb

input:

2
3
1
4
0
0
0
1
1
0
1
0
1

output:

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

result:

ok max_C=2.00, avg_C=1.00 (2 test cases)

Test #2:

score: 0
Accepted
time: 28ms
memory: 7696kb

input:

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

output:

? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
...

result:

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

Test #3:

score: -100
Wrong Answer
time: 119ms
memory: 7528kb

input:

100
10
1
0
1
1
1
1
0
1
0
1
1
1
0
1
0
0
1
0
1
0
0
0
1
-1

output:

? 1 6
? 2 6
? 3 6
? 4 6
? 5 6
? 6 6
? 7 6
? 8 6
? 9 6
? 10 6
? 6 1
? 6 2
? 6 3
? 6 4
? 6 5
? 7 3
? 8 3
? 9 3
? 10 3
? 9 4
? 9 5
? 7 5
? 8 5
! 6 5

result:

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