比赛 |
4043级2023省选模拟赛8 |
评测结果 |
AAAAAAAAAAAAAA |
题目名称 |
Stamp Grid |
最终得分 |
100 |
用户昵称 |
zxhhh |
运行时间 |
0.006 s |
代码语言 |
C++ |
内存使用 |
2.46 MiB |
提交时间 |
2023-03-29 19:53:05 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N = 25;
int t, n, k, mk[N][N];
char a[N][N], b[N][N], tmp[N][N];
void check (int x, int y) {
for (int i = 0;i < k;i++) {
for (int j = 0;j < k;j++) {
if (a[i+x][j+y] == '.' && b[i+1][j+1] == '*') return;
}
}
for (int i = 0;i < k;i++) {
for (int j = 0;j < k;j++) {
if (b[i+1][j+1] == '*') mk[i+x][j+y] = 1;
}
}
}
int main () {
freopen("yinzhang.in", "r", stdin);
freopen("yinzhang.out", "w", stdout);
cin >> t;
while (t--) {
memset(mk, 0, sizeof(mk));
cin >> n;
for (int i = 1;i <= n;i++) scanf("%s", a[i]+1);
cin >> k;
for (int i = 1;i <= k;i++) scanf("%s", b[i]+1);
for (int cnt = 1;cnt <= 4;cnt++) {
for (int i = 1;i <= n-k+1;i++) {
for (int j = 1;j <= n-k+1;j++) check(i, j);
}
for (int i = 1;i <= k;i++) for (int j = 1;j <= k;j++) tmp[i][j] = b[i][j];
for (int i = 1;i <= k;i++) for (int j = 1;j <= k;j++) b[j][k-i+1] = tmp[i][j];
}
int flag = 1;
for (int i = 1;i <= n;i++) {
for (int j = 1;j <= n;j++) {
if (a[i][j] == '*' && !mk[i][j]) {flag = 0; break;}
}
}
if (flag) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}