Loading

联考Day5

A.遗忘之祭仪

暴搜没敢写,,,,,
直接跳了然后没分

Code
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

inline int read(){
	int x = 0, w = 1;
	char ch = getchar();
	for(; ch > '9' || ch < '0'; ch = getchar()) if(ch == '-') w = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	return x * w;
}

inline void write(register int x){
	if(x < 0) x = ~x + 1, putchar('-');
	if(x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

const int ss = 1005;
struct Node {
	int x, y;
}d[ss * ss];
int cnt;
char c[ss][ss];
bool flag;

int main() {
	freopen("prepare.in", "r", stdin);
	freopen("prepare.out", "w", stdout);
	register int T = read();
	while (T--) {
		flag = cnt = 0;
		register int n = read(), m = read(), a = read(), b = read();
		for (int i = 1; i <= n; ++i)
			scanf("%s", c[i] + 1);
		for (int i = 0; i < a; ++i) {
			scanf("%s", c[0]);
			for (int j = 0; j < b; ++j)
				if (c[0][j] == 'x')
					d[++cnt] = (Node) {i, j};
		}
		for (int i = cnt; i >= 1; --i)
			d[i].x -= d[1].x, d[i].y -= d[1].y;
		for (int i = 1; i <= n && !flag; ++i) {
			for (int j = 1; j <= m && !flag; ++j) {
				if (c[i][j] == '.') continue;
				for (int k = 1; k <= cnt; ++k) {
					int x = i + d[k].x, y = j + d[k].y;
					if (x < 1 || x > n || y < 1 || y > m || c[x][y] == '.') 
						flag = 1, k = cnt;
					c[x][y] = '.';
				}
			}
		}
		puts(flag || !cnt ? "No" : "Yes");
	}
	return 0;
}

剩下的不会改了,跳了

posted @ 2020-10-18 16:23  Gary_818  阅读(28)  评论(5编辑  收藏