abc 326 D
暴力
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
string C, R;
cin >> N >> R >> C;
vector<int> row(N), col(N);
vector<string> ans(N, string(N, '.'));
int tot = 0;
auto dfs = [&](auto self, int x, int y) {
if (x == N) {
if (tot == 3 * N) {
cout << "Yes" << endl;
for (int i = 0; i < N; i ++)
cout << ans[i] << '\n';
exit(0);
}
//cout << tot << endl;
return;
}
if (y == N) return self(self, x + 1, 0);
self(self, x, y + 1);
for (int i = 0; i < 3; i ++) {
if ((row[x] >> i & 1) || (col[y] >> i & 1)) {
continue;
}
if (row[x] == 0 && 'A' + i != R[x]) continue;
if (col[y] == 0 && 'A' + i != C[y]) continue;
row[x] ^= 1 << i;
col[y] ^= 1 << i;
tot ++ ;
ans[x][y] = 'A' + i;
self(self, x, y + 1);
tot -- ;
ans[x][y] = '.';
row[x] ^= 1 << i;
col[y] ^= 1 << i;
}
};
dfs(dfs, 0, 0);
cout << "No\n";
return 0;
}