传送门: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;
}

  

最新文章

  1. 【Java EE 学习 27】【oracle学习第一天】
  2. 1336 - Sigma Function---LightOj1336
  3. node.js学习之路
  4. hdu 1272 小希的迷宫
  5. consul模板配置参数值示例
  6. vue.js使用详解
  7. nginx负载均衡的实现
  8. 【POJ】【2449】Remmarguts&#39; Date
  9. 546A. Soldier and Bananas
  10. How to Map Distinct Value Types Using Java Generics--reference
  11. 关于C#中Thread.Join()的一点理解
  12. Git学习 -- 分支管理
  13. delphi字符串操作函数一览
  14. assembly 基础
  15. Apache Traffic Server服务搭建
  16. linux最常用的基本命令
  17. SmartSql Cache标签
  18. 『计算机视觉』mini深度学习框架实现
  19. 050 sqoop的使用
  20. fang99-三号线与四号线新盘

热门文章

  1. 如何利用Fluxion诱惑目标用户获取WPA密码
  2. simple-todo: 一个简易的 todo 程序 - django版
  3. &amp;quot;undefined reference to strptime&amp;quot;之自己定义strptime函数
  4. Centos7 Samba 独立账户
  5. Linux 命令 sudo
  6. Linux下进程信息的深入分析
  7. 阿里云 oss 小文件上传进度显示
  8. Python开发【第2节】【Python运算符】
  9. Apache Hadoop 和Hadoop生态圈
  10. 树莓派 mongodb 安装&amp;报错处理