跳到正文

题解

题解:CF1906C Cursed Game

drmr约 4 分钟
原文
文章信息与版本

文章信息

发布
2025年9月1日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 4 分钟
题目
CF1906C

版本

  1. v1当前

为什么有 *3000?

对于 5≤N5 \le N,先输出矩阵 AA,满足 Ai,j=[i=3∧j=3]A_{i, j} = [i = 3 \wedge j = 3],这样就可以问出洞的位置,然后构造即可。

对于 N=3N = 3 直接随机输出即可,期望 22 步。

所以期望花费 666666 步。

(而且说这样一个题为啥要放 100+ 个测试点啊)

C++
#include <bits/stdc++.h>
using namespace std;

mt19937 rnd(time(0));
int n, a[500][500], b[500][500];

void solve(){
	cin >> n;
	if(n == 3){
		while(true){
			for(int i = 1; i <= 3; i++){
				for(int j = 1; j <= 3; j++)
					cout << (rnd() & 1);
				cout << "\n";
			}
			cout << flush;
			string s;
			cin >> s;
			if(s == "CORRECT") return ;
			else cin >> s;
		}
		return ;
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++)
			cout << (i == 3 && j == 3);
		cout << "\n";
	}
	cout << flush;

	string s;
	cin >> s;
	if(s == "CORRECT") return ;

	for(int i = 1; i <= 3; i++)
		for(int j = 1; j <= 3; j++)
			a[i][j] = 0;
	for(int i = 1; i <= n - 2; i++)
		for(int j = 1; j <= n - 2; j++){
			char x; cin >> x;
			if(i <= 3 && j <= 3)
				a[4 - i][4 - j] = x - '0';
		}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)
		b[i][j] = -1;

	for(int i = 1; i <= n - 2; i++)
		for(int j = 1; j <= n - 2; j++){
			int sum = 0;
			for(int x = 1; x <= 3; x++)
				for(int y = 1; y <= 3; y++)
					if(a[x][y] && b[i + x - 1][j + y - 1] != -1)
						sum ^= b[i + x - 1][j + y - 1];
			for(int x = 1; x <= 3; x++)
				for(int y = 1; y <= 3; y++)
					if(a[x][y] && b[i + x - 1][j + y - 1] == -1){
						if(!sum) b[i + x - 1][j + y - 1] = 1, sum = 1;
						else b[i + x - 1][j + y - 1] = 0;
					}
		}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++)
			cout << max(0, b[i][j]);
		cout << "\n";
	}
	cout << flush;
	cin >> s;
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T = 333;
	while(T--) solve();
	return 0;
}
原文