CodeForcesGym 100753B Bounty Hunter II
2015-10-05 19:30
246 查看
Bounty Hunter II
Time Limit: 5000msMemory Limit: 262144KB
This problem will be judged on CodeForcesGym. Original ID: 100753B
64-bit integer IO format: %I64d Java class name: (Any)
#include <bits/stdc++.h> using namespace std; const int maxn = 4010; vector<int>g[maxn]; int Link[maxn],n; bool used[maxn]; bool match(int u){ for(int i = g[u].size()-1; i >= 0; --i){ if(used[g[u][i]]) continue; used[g[u][i]] = true; if(Link[g[u][i]] == -1 || match(Link[g[u][i]])){ Link[g[u][i]] = u; return true; } } return false; } int main(){ int m; while(~scanf("%d",&n)){ for(int i = 0; i < maxn; ++i) g[i].clear(); for(int i = 0; i < n; ++i){ scanf("%d",&m); for(int j = 0,v; j < m; ++j){ scanf("%d",&v); g[i].push_back(v + n); } } memset(Link,-1,sizeof Link); int ret = 0; for(int i = 0; i < n; ++i){ memset(used,false,sizeof used); if(match(i)) ++ret; } printf("%d\n",n - ret); } } /* 4 1 1 1 2 0 1 1 6 0 1 2 2 4 5 1 2 0 0 5 1 4 1 4 1 4 1 4 0 */
View Code
相关文章推荐
- 12 java.util.LinkedList
- Android-----test----monkeyrunner
- 论文返修(response letter)一些很有用的套话
- Ubuntu升级后apache所有的失败,以解决虚拟文件夹的设置
- Part 3 ViewData and ViewBag in mvc
- 不懂
- 高效能人士的起个习惯
- <七>账号管理
- 【Leetcode算法】- Add Binary
- ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题
- 黑马程序员—常见API
- EffectiveC#1--尽可能的使用属性(property),而不是数据成员(field)
- Centroid - SGU 134(树的搜索)
- 前景提取--Subspace learning models
- why delete Scene crash!
- iOS编程------- UITableViewController
- POJ3573(模拟)
- C#删除和清空文件夹的程序
- CodeForcesGym 100753E Change of Scenery
- [转]Android中自定义checkbox样式