hdu 2063 过山车
来源:互联网 发布:在淘宝上怎么注册店铺 编辑:程序博客网 时间:2024/04/29 17:23
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2063
题目大意:
中文题,不解释。
题目思路:
裸的二分匹配。
匈牙利,网络流。。。随便搞
刚看完匈牙利,测测自己的代码。。。
代码:
#include <stdlib.h>#include <string.h>#include <stdio.h>#include <ctype.h>#include <math.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <string>#include <iostream>#include <algorithm>using namespace std;#define ll long long#define ls rt<<1#define rs ls|1#define lson l,mid,ls#define rson mid+1,r,rs#define middle (l+r)>>1#define eps (1e-8)#define clr_all(x,c) memset(x,c,sizeof(x))#define clr(x,c,n) memset(x,c,sizeof(x[0])*(n+1))#define MOD 1000000009#define INF 0x3f3f3f3f#define pi acos(-1.0)#define _max(x,y) (((x)>(y))? (x):(y))#define _min(x,y) (((x)<(y))? (x):(y))#define _abs(x) ((x)<0? (-(x)):(x))#define getmin(x,y) (x= ((x)<0 || (y)<(x))? (y):(x))#define getmax(x,y) (x= ((y)>(x))? (y):(x))template <class T> void _swap(T &x,T &y){T t=x;x=y;y=t;}int TS,cas=1;const int M=500+5;int k,m,n;struct hungary{int n,m; //X集和Y集的点数int match[M]; //匹配bool vis[M]; //是否在增广路上vector<int>g[M]; //邻接表void init(int _n,int _m){n=_n,m=_m,clr(match,-1,m);for(int i=0;i<n;i++) g[i].clear();}void insert(int u,int v){g[u].push_back(v);}bool augment(int u){//增广for(int i=0,v;i<g[u].size();i++){if(!vis[v=g[u][i]]){vis[v]=1;if(match[v]==-1 || augment(match[v])){match[v]=u;return true;}}}return false;}int maxMatch(){int res=0;for(int i=0;i<n;i++){clr(vis,0,m);if(augment(i)) res++;}return res;}}p;void run(){ int i,j;scanf("%d%d",&m,&n);p.init(m,n);while(k--){int a,b;scanf("%d%d",&a,&b);p.insert(a-1,b-1);}printf("%d\n",p.maxMatch());}void preSof(){}int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); preSof(); //run(); while(~scanf("%d",&k) && k) run(); //for(scanf("%d",&TS);cas<=TS;cas++) run(); return 0;}
- hdu 2063 过山车
- hdu 2063 过山车
- HDU-2063 过山车
- HDU 2063 过山车
- HDU 2063 过山车
- hdu 2063 过山车
- HDU 2063 过山车
- HDU 2063 过山车
- hdu 2063 过山车
- hdu 2063 过山车
- hdu 2063 过山车
- HDU 2063 过山车
- HDU 2063 过山车
- hdu 2063 过山车
- HDU 2063 过山车
- hdu 2063(过山车)
- hdu 2063 过山车
- hdu 2063 过山车
- matlab2010a在mbuild时找不到vs2010的解决办法
- 虚拟对象的属性描述
- Oracle 11g安装中遇到的问题及解决方法
- html中走马灯相关参数的意义和设置
- 从数据库中导入导出文件
- hdu 2063 过山车
- 让作者告诉你DirectX修复工具到底能解决什么问题
- Linux 分区命名
- 工作笔记整理
- Fusion Charts导出图片或Pdf
- CGContextDrawImage画图
- UML用例图之泛化(generalization)、扩展(extend)和包含(include)关系--UML一波流系列讲解
- RHEL安装Hyper-V集成服务后无法使用光驱的解决方法
- nfs:server is not responding,still trying 解决