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 |
删掉,或者不扫0,0,的边。#include <stdio.h> #include <string.h> int n,m,k; bool maps[105][105]; int match[1050]; bool use[1050]; bool DFS(int u) { for(int i=1;i<m;i++) { if(!use[i]&&maps[u][i]) { use[i] = true; if(match[i]==-1||DFS(match[i])) { match[i] = u; return true; } } } return false; } int main() { while(scanf("%d",&n)) { if(n==0) break; scanf("%d%d",&m,&k); memset(maps,false,sizeof(maps)); memset(match,-1,sizeof(match)); for(int i=0;i<k;i++) { int t,a,b; scanf("%d%d%d",&t,&a,&b); maps[a][b] = true; } /*for(int i=0;i<m;i++) { if(maps[0][i]) maps[0][i] = false; } for(int i=0;i<n;i++) { if(maps[i][0]) maps[i][0] = false; }*/ int num = 0; for(int i=1;i<n;i++) { memset(use,false,sizeof(use)); if(DFS(i)) num++; } printf("%d\n",num); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator