Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一次就ac了!爽死了!呵呵呵!#include <stdio.h> #include <string.h> #define len 310 int map[len][len]; int used[len],link[len]; int dfs(int a) { int i; for(i=1;i<=len;i++) { if(!used[i]&&map[a][i]) { used[i]=1; if(link[i]==-1||dfs(link[i])) { link[i]=a; return 1; } } } return 0; } int main() { int n,m,i,a,b,sum; while(scanf("%d",&n)!=EOF) { memset(map,0,sizeof(map)); memset(link,-1,sizeof(link)); for(i=1;i<=n;i++) { scanf("%d",&m); map[i][0]=m; while(m--) { scanf("%d %d",&a,&b); map[i][12*a+b]=1; } } sum=0; for(i=1;i<=n;i++) { memset(used,0,sizeof(used)); if(dfs(i)) sum++; } printf("%d\n",sum); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator