题解
查看原帖
题解
728084
Npsy202206楼主2024/8/27 15:43
#include<bits/stdc++.h>
#define tt typedef

using namespace std;
tt int ii;
tt char cc;
tt float ff;
tt double dd;
tt string st;
tt long long ll;
template <typename T>
void read(T &x) {
	x = 0;
	cc ch = getchar();
	while (ch < '0' || ch > '9') {
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
}
struct ghy {
	cc name[21];
	ii board[5][5];
	bool jzl(const ii* c, ii m)const {
		for (ii i = 0; i < 5; i++) {
			bool r = true;
			for (ii j = 0; j < 5; j++) {
				bool found = false;
				for (ii k = 0; k < m; k++) {
					if (c[k] == board[i][j]) {
						found = true;
						break;
					}
				}
				if (!found) {
					r = false;
					break;
				}
			}
			if (r) return true;
		}
		for (ii j = 0; j < 5; j++) {
			bool bingo = true;
			for (ii i = 0; i < 5; i++) {
				bool found = false;
				for (ii k = 0; k < m; k++) {
					if (c[k] == board[i][j]) {
						found = true;
						break;
					}
				}
				if (!found) {
					bingo = false;
					break;
				}
			}
			if (bingo) return true;
		}
		bool d = true;
		for (ii i = 0; i < 5; i++) {
			bool found = false;
			for (ii k = 0; k < m; k++) {
				if (c[k] == board[i][i]) {
					found = true;
					break;
				}
			}
			if (!found) {
				d = false;
				break;
			}
		}
		if (d) return true;
		bool d1 = true;
		for (ii i = 0; i < 5; i++) {
			bool found = false;
			for (ii k = 0; k < m; k++) {
				if (c[k] == board[i][4 - i]) {
					found = true;
					break;
				}
			}
			if (!found) {
				d1 = false;
				break;
			}
		}
		return d1;
	}
};
ii n,m,cnt=0;
ii main() {
//	freopen("bingo.in","r",stdin);
//	freopen("bingo.out","w",stdout);
	read(n);
	ghy players[n];
	for (ii i = 0; i < n; i++) {
//		cin >> players[i].name;
        scanf("%s",players[i].name);
		for (ii j = 0; j < 5; j++) {
			for (ii k = 0; k < 5; k++) {
				read(players[i].board[j][k]); 
			}
		}
	}
	read(m);
	ii called[m];
	for (ii i = 0; i < m; i++) {
		read(called[i]);
	}
	for (ii i = 0; i < n; i++) {
		if (players[i].jzl(called, m)) {
			cnt++;
		}
	}
//	cout << cnt << endl;
    printf("%d\n",cnt);
	for (ii i = 0; i < n; i++) {
		if (players[i].jzl(called, m)) {
//			cout << players[i].name << endl;
            printf("%s\n",players[i].name);
		}
	}
	return 0;
}
2024/8/27 15:43
加载中...