标签:pac pat write ram set line ... enter max
Time Limit: 5000MS | Memory Limit: 10000K | |
Total Submissions: 12717 | Accepted: 5659 |
Description
Input
Output
Sample Input
7 0: (3) 4 5 6 1: (2) 4 6 2: (0) 3: (0) 4: (2) 0 1 5: (1) 0 6: (2) 0 1 3 0: (2) 1 2 1: (1) 0 2: (1) 0
Sample Output
5 2
Source
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define N 500+10 int map[N][N],match[N]; int cnt,n,m,id,num,po; bool vis[N]; bool path(int x) { for(int i=0;i<n;i++) { if(!vis[i]&&map[x][i]) { vis[i]=1; if(!match[i]||path(match[i])) { match[i]=x; return true; } } } return false; } int main() { while(cin>>n) { cnt=0; memset(map,0,sizeof(map)); memset(match,0,sizeof(match)); for(int i=1;i<=n;i++) { scanf("%d: (%d)",&id,&num); for(int j=1;j<=num;j++) { scanf("%d",&po); map[id][po]=1; } } for(int i=0;i<n;i++) { memset(vis,0,sizeof(vis)); if(path(i))cnt++; } cout<<n-cnt/2<<endl; } return 0; }
标签:pac pat write ram set line ... enter max
原文地址:http://www.cnblogs.com/zzyh/p/6842607.html