POJ
来源:互联网 发布:淘宝怎么用邮箱注册 编辑:程序博客网 时间:2024/06/02 20:24
个人赛题目
会 匈牙利算法 的话 套上模板就是 ,理解的还不算透彻,先放在 博客上,下次找个全面的匈牙利算法的题 理解透彻了,一齐写理解
#include<iostream> // 模板--匈牙利算法#include<cstdio>#include<cstring>using namespace std;const int maxn = 500 + 10;int n, k, ans;int mp[maxn][maxn];int vis[maxn];int link[maxn];void init() { int r, c; for(int i = 0; i < k; ++i) { scanf("%d%d", &r, &c); mp[r][c] = 1; }}bool dfs(int x) { for(int y = 1; y <= n; ++y) { if(mp[x][y] && !vis[y]) { vis[y] = 1; if(link[y] == 0 || dfs(link[y])) { link[y] = x; return true; } } } return false;}void solve() { for(int x = 1; x <= n; ++x) { memset(vis, 0, sizeof vis); if(dfs(x)) ans++; } cout << ans << endl;}int main() { memset(mp, 0, sizeof mp); memset(link, 0, sizeof link); cin >> n >> k; init(); solve(); return 0;}/*3 41 11 32 23 2*/
阅读全文
1 0
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- VCS-5续2 LVM和VxVM
- 关于File文件类使用
- 二极管结构和工作原理
- 《Ray Tracing in One Weekend》——Chapter 2: The vec3 class
- 4. ESP8266固件的编译(NONOS SDK固件 AT固件)
- POJ
- Linux命令对应英文全称
- ABOUT INTERNET
- 你应该需要了解到的 【HTTP状态码 】
- android gps机制分析--之二
- scala中的方法与函数
- ubuntu下安装软件常用的3种方法
- LeetCode算法题目:Sort Colors
- 虚拟机VMware 中安装CentOS 系统的方法