标签:des style blog http color java os io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5817 Accepted Submission(s): 2932
1 #include<cstring> 2 #include<cstdio> 3 #include<cstdlib> 4 using namespace std; 5 int const maxn=102; 6 int n,m,k; 7 bool mat[maxn][maxn]; 8 bool vis[maxn]; 9 int mac[maxn]; 10 bool match(int x) 11 { 12 for(int i=1;i<=m;i++) 13 { 14 if(mat[x][i]&&!vis[i]){ 15 vis[i]=1; 16 if(!mac[i]||match(mac[i])){ 17 mac[i]=x; 18 return 1; 19 } 20 } 21 } 22 return 0; 23 } 24 int main(){ 25 int a,b,c; 26 //freopen("test.in","r",stdin); 27 while(scanf("%d",&n),n!=0){ 28 memset(mat,0,sizeof(mat)); 29 memset(mac,0,sizeof(mac)); 30 scanf("%d%d",&m,&k); 31 for(int i=0;i<k;i++){ 32 scanf("%d%d%d",&a,&b,&c); 33 mat[b][c]=1; 34 } 35 int ans=0; 36 for(int i=1;i<=n;i++){ 37 memset(vis,0,sizeof(vis)); 38 if(match(i))ans++; 39 } 40 printf("%d\n",ans); 41 } 42 return 0; 43 }
hdu-----(1150)Machine Schedule(最小覆盖点),布布扣,bubuko.com
hdu-----(1150)Machine Schedule(最小覆盖点)
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/gongxijun/p/3928013.html