标签:ssi tput put single space typedef nes empty 二分
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 23963 | Accepted: 12989 |
Description
Input
Output
Sample Input
3 4 1 1 1 3 2 2 3 2
Sample Output
2
Hint
1 #include <stdio.h> 2 #include <math.h> 3 #include <string.h> 4 #include <stdlib.h> 5 #include <iostream> 6 #include <sstream> 7 #include <algorithm> 8 #include <string> 9 #include <queue> 10 #include <ctime> 11 #include <vector> 12 using namespace std; 13 const int maxn= 25; 14 const int maxm=500+10; 15 const int inf = 0x3f3f3f3f; 16 typedef long long ll; 17 int n,m; 18 int match[maxm]; 19 bool visited[maxm]; 20 bool mp[maxm][maxm]; 21 bool Find(int x){ 22 for(int i=1;i<=n;i++){ 23 if(mp[x][i]&&visited[i]==0){ 24 visited[i]=true; 25 if(match[i]==0||Find(match[i])){ 26 match[i]=x; 27 return true; 28 } 29 } 30 } 31 return false; 32 } 33 int main(){ 34 int x,y,num; 35 while(~scanf("%d%d",&n,&m)){ 36 memset(mp,0,sizeof(mp)); 37 memset(match,0,sizeof(match)); 38 memset(visited,0,sizeof(visited)); 39 for(int i=0;i<m;i++){ 40 scanf("%d%d",&x,&y); 41 mp[x][y]=true; 42 } 43 num=0; 44 for(int i=1;i<=n;i++){ 45 memset(visited,0,sizeof(visited)); 46 if(Find(i))num++; 47 } 48 printf("%d\n",num); 49 } 50 return 0; 51 }
溜啦溜啦,去写多校的二分图的题啦。
标签:ssi tput put single space typedef nes empty 二分
原文地址:http://www.cnblogs.com/ZERO-/p/7806000.html