QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77259#4884. Battleship: New RuleshuzhaoyangWA 75ms7576kbC++141.4kb2023-02-13 19:50:302023-02-13 19:50: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-02-13 19:50:32]
  • 评测
  • 测评结果:WA
  • 用时:75ms
  • 内存:7576kb
  • [2023-02-13 19:50:30]
  • 提交

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,lst=0;i<y2;i++){
		int now=query(x1-1,i);
		s^=(lst&now),lst=now;
	}
	for(int i=y1,lst=0;i<y2;i++){
		int now=query(x2,i);
		s^=(lst&now),lst=now;
	}
	for(int i=x1,lst=0;i<x2;i++){
		int now=query(i,y1-1);
		s^=(lst&now),lst=now;
	}
	for(int i=x1,lst=0;i<x2;i++){
		int now=query(i,y2);
		s^=(lst&now),lst=now;
	}
	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: 2ms
memory: 7576kb

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: 40ms
memory: 7384kb

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: 75ms
memory: 7448kb

input:

100
10
1
0
1
1
1
1
0
1
0
1
1
1
0
1
0
1
0
1
0
0
1
0
0
0
-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
? 1 3
? 2 3
? 3 3
? 4 3
? 5 3
? 3 1
? 3 2
? 1 2
? 2 2
! 2 2

result:

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