QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384291#4884. Battleship: New RuleszhoukangyangRE 1ms5780kbC++141.9kb2024-04-09 21:27:122024-04-09 21:27:12

Judging History

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

  • [2024-04-09 21:27:12]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5780kb
  • [2024-04-09 21:27:12]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
#define pb emplace_back
using namespace std;
#define i128 __int128
const int N = 2e3 + 7;
int n;
bool vis[N][N]; 

bool gr[N][N];
int query(int x, int y) {
	cout << "? " << x << ' ' << y << endl;
//	return gr[x][y];
	int w;
	cin >> w;
	return w;
}
void report(int x, int y) {
	cout << "! " << x << ' ' << y << endl;
	int w;
	cin >> w;
	if(w == -1)assert(false);
}
void dc(int l1, int r1, int l2, int r2) {
	if(l1 == r1 && l2 == r2) {
		if(l1 == 0 || r1 == 0 || l2 == n || r2 == n) {
			report(-1, -1);
		} else {
			report(l1, r1);
		}
		return;
	}
	if(r1 - l1 > r2 - l2) {
		int m1 = (l1 + r1) >> 1;
		L(j, l2 + 1, r2) if(m1) {
			int u = query(m1, j);
			if(u) vis[m1][j] = vis[m1][j - 1] = vis[m1 - 1][j] = vis[m1 - 1][j - 1] = 1;
		}
		int op = 0;
		L(i, l1, m1) L(j, l2, r2)op ^= !vis[i][j];
		if(op)dc(l1, m1, l2, r2);
		else dc(m1 + 1, r1, l2, r2);
	} else {
		int m2 = (l2 + r2) >> 1;
		L(j, l1 + 1, r1) if(m2) {
			int u = query(j, m2);
			if(u) vis[j][m2] = vis[j - 1][m2] = vis[j][m2 - 1] = vis[j - 1][m2 - 1] = 1;
		}
		int op = 0;
		L(i, l1, r1) L(j, l2, m2)op ^= !vis[i][j];
		if(op)dc(l1, r1, l2, m2);
		else dc(l1, r1, m2 + 1, r2);
	}
}
void Main() {
	cin >> n;
	if(n % 2 == 1) {
		report(-1, -1);
		return ;
	}
	L(i, 0, n) L(j, 0, n)vis[i][j] = 0;
	dc(0, n, 0, n);
}
int main() {
	gr[1][1] = 1;
	gr[1][2] = 1;
	gr[3][1] = 1;
	gr[4][1] = 1;
	gr[1][4] = 1;
	gr[2][4] = 1;
	gr[4][3] = 1;
	gr[4][4] = 1;
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t; cin >> t; while(t--) Main();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5780kb

input:

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

output:

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

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 5648kb

input:

100
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
1
1
1
4
0
0
0
1
1
0
1
1
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
1
1
1
4
0
0
0
1
1
0
1
1
1
4
0
0
0
1
1
0
1
1
1
4
0
0
0
1
1
0
1
1
1
4
1
0
0
0
0
0
1
0
1
4
0
0
0
1
1
0
1
1
1
4
1
0
0
0
0
0
1
0
1
4
1
0
0
0
0
0
1
...

output:

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

result:

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

Test #3:

score: -100
Runtime Error

input:

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

output:

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

result: