CF989C 题解
思路
把 的矩阵分割成四个 的小矩阵,分别存四个字母。然后因为方格充足,所以可以在不破坏原先 A 矩阵的情况下在其中存 个 D,其余同理。因为资源充足,所以其中一种解决方案就是间隔着放字母。
代码
# include <bits/stdc++.h>
using namespace std;
int a, b, c, d, x, y;
char ans[55][55];
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> a >> b >> c >> d;
cout << "50 50";
for (int i = 0; i < 25; ++ i)
for (int j = 0; j < 25; ++ j)
ans[i][j] = 'A';
for (int i = 0; i < 25; ++ i)
for (int j = 25; j < 50; ++ j)
ans[i][j] = 'B';
for (int i = 25; i < 50; ++ i)
for (int j = 0; j < 25; ++ j)
ans[i][j] = 'C';
for (int i = 25; i < 50; ++ i)
for (int j = 25; j < 50; ++ j)
ans[i][j] = 'D';
x = y = 1;
while (-- d) {
ans[x][y] = 'D';
if ((y += 2) > 24)
x += 2, y = 1;
}
x = 1, y = 26;
while (-- c) {
ans[x][y] = 'C';
if ((y += 2) > 49)
x += 2, y = 26;
}
x = 26, y = 1;
while (-- b) {
ans[x][y] = 'B';
if ((y += 2) > 24)
x += 2, y = 1;
}
x = y = 26;
while (-- a) {
ans[x][y] = 'A';
if ((y += 2) > 49)
x += 2, y = 26;
}
for (int i = 0; i < 50; ++ i)
cout << '\n' << ans[i];
return 0;
}

浙公网安备 33010602011771号