标签:des style blog http color java os io
2 4 3 3 4 1 3 2 3 3 3 1 3 1 2 2 3
2 1
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 const int maxn = 200; 18 int mp[maxn][maxn],from[maxn],n,m; 19 bool vis[maxn]; 20 bool dfs(int u){ 21 for(int v = 1; v <= n; v++){ 22 if(mp[u][v] && !vis[v]){ 23 vis[v] = true; 24 if(from[v] == -1 || dfs(from[v])){ 25 from[v] = u; 26 return true; 27 } 28 } 29 } 30 return false; 31 } 32 int main() { 33 int t,u,v,ans,i; 34 scanf("%d",&t); 35 while(t--){ 36 scanf("%d %d",&n,&m); 37 memset(mp,0,sizeof(mp)); 38 memset(from,-1,sizeof(from)); 39 for(i = 0; i < m; i++){ 40 scanf("%d %d",&u,&v); 41 mp[u][v] = 1; 42 } 43 ans = 0; 44 for(i = 1; i <= n; i++){ 45 memset(vis,false,sizeof(vis)); 46 if(dfs(i)) ans++; 47 } 48 printf("%d\n",n-ans); 49 } 50 return 0; 51 }
BNUOJ 1541 Air Raid,布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/crackpotisback/p/3907251.html