【poj1274】 The Perfect Stall
来源:互联网 发布:matlab定义空矩阵 编辑:程序博客网 时间:2024/05/16 16:08
http://poj.org/problem?id=1274 (题目链接)
题意:懒得写了
Solution
二分图匹配裸题。注意清空数组。
代码:
// poj3020#include<algorithm>#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<cmath>#define LL long long#define inf 2147483640#define Pi 3.1415926535898#define free(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);using namespace std;const int maxn=500;struct edge {int next,to;}e[maxn<<2];int head[maxn],p[maxn],vis[maxn],cnt,n,m;void insert(int u,int v) { e[++cnt].to=v;e[cnt].next=head[u];head[u]=cnt;}bool find(int x) { for (int i=head[x];i;i=e[i].next) if (!vis[e[i].to]) { vis[e[i].to]=1; if (p[e[i].to]==0 || find(p[e[i].to])) { p[e[i].to]=x; return 1; } } return 0;}int main() { while (scanf("%d%d",&n,&m)!=EOF) { for (int i=1;i<=n;i++) p[i]=head[i]=0; cnt=0; for (int i=1;i<=n;i++) { int x;scanf("%d",&x); for (int j=1;j<=x;j++) { int t;scanf("%d",&t); insert(i,t); } } int ans=0; for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++) vis[j]=0; if (find(i)) ans++; } printf("%d\n",ans); } return 0;}
0 0
- POJ1274 The Perfect Stall
- POJ1274 The Perfect Stall
- poj1274 - The Perfect Stall
- poj1274 The Perfect Stall
- POJ1274 The Perfect Stall
- 【poj1274】 The Perfect Stall
- POJ1274 The Perfect Stall
- POJ1274-The Perfect Stall
- POJ1274 The Perfect Stall
- POJ1274-The Perfect Stall
- POJ1274: The Perfect Stall 题解
- poj1274 The Perfect Stall (匈牙利算法)
- POJ1274--The Perfect Stall(最大流)
- 解题报告 之 POJ1274 The Perfect Stall
- POJ1274 The Perfect Stall(二分图)
- poj1274 The Perfect Stall(二分图匹配)
- USACO Section4.2 The Perfect Stall &&POJ1274
- poj1274 The Perfect Stall【二分图匹配】
- ACDream 1067 Convex
- 校招算法复习之冒泡排序
- STL中的set容器的一点总结
- 数据结构实验之排序三:bucket sort
- CodeForce 706C 动态规划 利用下标表示状态 递推 (伪状态压缩)
- 【poj1274】 The Perfect Stall
- Thinkphp 微博项目
- 网络广告CPC、CPM和CTR的定义和关系
- HDU 1072/BFS
- eclipse maven安装配置
- POJ 2019 Cornfields (二维RMQ)
- 使用loadrunner编写dubbo接口的性能测试脚本
- codeforces 706D. Vasiliy's Multiset 带删除操作的字典树(真模版)
- 黄阶低级 - 《 Java 核心》- 3.7 输入输出 - 修改0次