QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384286#4884. Battleship: New RuleszhoukangyangWA 1ms3664kbC++141.8kb2024-04-09 21:25:372024-04-09 21:25:37

Judging History

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

  • [2024-04-09 21:25:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3664kb
  • [2024-04-09 21:25:37]
  • 提交

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) {
			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) {
			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: 0
Wrong Answer
time: 1ms
memory: 3664kb

input:

2
3

output:

-1 -1

result:

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