标签: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): 3378 Accepted Submission(s): 2223
1 #include<cstring> 2 #include<cstdio> 3 #include<cstdlib> 4 using namespace std; 5 int const maxn=122; 6 int n,m; 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; 26 int test; 27 //freopen("test.in","r",stdin); 28 scanf("%d",&test); 29 while(test--){ 30 scanf("%d%d",&m,&n); 31 memset(mat,0,sizeof(mat)); 32 memset(mac,0,sizeof(mac)); 33 for(int i=0;i<n;i++){ 34 scanf("%d%d",&a,&b); 35 mat[a][b]=1; 36 } 37 38 int ans=0; 39 for(int i=1;i<=m;i++){ 40 memset(vis,0,sizeof(vis)); 41 if(match(i))ans++; 42 } 43 printf("%d\n",m-ans); 44 } 45 return 0; 46 }
hdu-----(1151)Air Raid(最小覆盖路径),布布扣,bubuko.com
hdu-----(1151)Air Raid(最小覆盖路径)
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/gongxijun/p/3928229.html