QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73759#4884. Battleship: New RulesAppleblue17WA 21ms3524kbC++141015b2023-01-27 22:00:022023-01-27 22:00:05

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 22:00:05]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:3524kb
  • [2023-01-27 22:00:02]
  • 提交

answer

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

int cal(int x,int y){
	if(x>n || y>n) return 0;
	if(f[x][y]!=-1) return f[x][y];
	cout<<"? "<<x<<" "<<y<<'\n';
	cin>>f[x][y];
	return f[x][y];
}

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';
		int s; cin>>s;
		return ;
	}
	if(R-L<r-l){
		solve(L,R,l,r,typ^1);
		return ;
	}
	int MID=(L+R)>>1;
	int tot=0,lst;
	for(int i=l-1;i<=r;i++) typ?cal(MID,i):cal(i,MID);
	lst=typ?cal(MID,l-1):cal(l-1,MID);
	for(int i=l;i<=r;i++){
		int s=typ?cal(MID,i):cal(i,MID);
		if(s || lst) tot++;
		lst=s;
	}
	
	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;
		for(int i=1;i<=n+1;i++)
			for(int j=1;j<=n+1;j++)
				f[i][j]=-1;
		if(n & 1){
			cout<<"! -1 -1"<<'\n';
			int s; cin>>s;
			continue;
		}
		solve(1,n+1,1,n+1,0);
	}
	
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3340kb

input:

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

output:

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

result:

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

Test #2:

score: 0
Accepted
time: 21ms
memory: 3524kb

input:

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

output:

? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 2 1
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 2 1
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 2 1
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 2 1
? 2 2
! 2 2
? 1 3
? 2 3
? 3 3
? 4 3
? 3 1
? 3 2
? 2 1
? 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: 1ms
memory: 3520kb

input:

100
10
1
0
1
1
1
1
0
1
0
1
1
1
0
1
0
0
1
0
1
0
0
1
1
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
? 7 3
? 8 3
? 9 3
? 10 3
? 9 1
? 9 2
? 8 1
? 8 2
? 7 2
! 6 2

result:

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