HDU 1179:Ollivanders: Makers of Fine Wands since 382 BC.
模板二分图:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m, f[maxn], ans, k, x;
bool mat[maxn][maxn];
int mac[maxn];
bool v[maxn];
int dfs(int x) {
for (int i = 1; i <= n; ++i)
if (mat[x][i] && !v[i]) {
v[i] = 1;
if (!mac[i] || dfs(mac[i])) {
mac[i] = x;
return 1;
}
}
return 0;
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
while (cin >> n && n) {
memset(mac, 0, sizeof mac);
memset(mat, 0, sizeof mat);
cin >> m;
for (int i = 1; i <= m; ++i) {
cin >> k;
while (k--)
cin >> x, mat[i][x] = 1;
}
ans = 0;
for (int i = 1; i <= m; ++i) {
memset(v, false, sizeof v);
if (dfs(i))ans++;
}
cout << ans << endl;
}
}
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 分享4款.NET开源、免费、实用的商城系统
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
· 5. Nginx 负载均衡配置案例(附有详细截图说明++)