_bzoj1059 [ZJOI2007]矩阵游戏【二分图匹配】
2024-08-30 15:17:05
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1059
保存匈牙利模板。
#include <cstdio>
#include <cstring> const int maxn = 205;
const char _outp[2][5] = {"No", "Yes"}; int T, n, left[maxn], ans;
char g[maxn][maxn], cover[maxn]; bool dfs(int i) {
for (int j = 1; j <= n; ++j) {
if (!g[i][j] || cover[j]) {
continue;
}
cover[j] = 1;
if (!left[j] || dfs(left[j])) {
left[j] = i;
return true;
}
}
return false;
} int main(void) {
//freopen("in.txt", "r", stdin);
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
ans = 0;
memset(left, 0, sizeof left);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
scanf("%d", (int*)(g[i] + j));
}
} for (int i = 1; i <= n; ++i) {
memset(cover, 0, sizeof cover);
if (dfs(i)) {
++ans;
}
}
puts(_outp[ans == n]);
}
return 0;
}
最新文章
- 【Java EE 学习 27】【oracle学习第一天】
- 1336 - Sigma Function---LightOj1336
- node.js学习之路
- hdu 1272 小希的迷宫
- consul模板配置参数值示例
- vue.js使用详解
- nginx负载均衡的实现
- 【POJ】【2449】Remmarguts&#39; Date
- 546A. Soldier and Bananas
- How to Map Distinct Value Types Using Java Generics--reference
- 关于C#中Thread.Join()的一点理解
- Git学习 -- 分支管理
- delphi字符串操作函数一览
- assembly 基础
- Apache Traffic Server服务搭建
- linux最常用的基本命令
- SmartSql Cache标签
- 『计算机视觉』mini深度学习框架实现
- 050 sqoop的使用
- fang99-三号线与四号线新盘
热门文章
- 如何利用Fluxion诱惑目标用户获取WPA密码
- simple-todo: 一个简易的 todo 程序 - django版
- &;quot;undefined reference to strptime&;quot;之自己定义strptime函数
- Centos7 Samba 独立账户
- Linux 命令 sudo
- Linux下进程信息的深入分析
- 阿里云 oss 小文件上传进度显示
- Python开发【第2节】【Python运算符】
- Apache Hadoop 和Hadoop生态圈
- 树莓派 mongodb 安装&;报错处理