标签:
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 5244 | Accepted: 2192 |
Description
Input
Output
Sample Input
2 4 35 M classicism programming 0 M baroque skiing 43 M baroque chess 30 F baroque soccer 8 27 M romance programming 194 F baroque programming 67 M baroque ping-pong 51 M classicism programming 80 M classicism Paintball 35 M baroque ping-pong 39 F romance ping-pong 110 M romance Paintball
Sample Output
3 7
Source
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <vector> 6 #include <queue> 7 #include <cmath> 8 #include <set> 9 using namespace std; 10 11 #define N 505 12 13 int max(int x,int y){return x>y?x:y;} 14 int min(int x,int y){return x<y?x:y;} 15 int abs(int x,int y){return x<0?-x:x;} 16 17 int n, m; 18 bool visited[N]; 19 vector<int>ve[N]; 20 int from[N]; 21 22 struct node{ 23 int h; 24 char sex[5]; 25 char music[105]; 26 char sport[105]; 27 }a[N]; 28 29 int march(int u){ 30 int i, j, k, v; 31 for(i=0;i<ve[u].size();i++){ 32 v=ve[u][i]; 33 if(!visited[v]){ 34 visited[v]=true; 35 if(from[v]==-1||march(from[v])){ 36 from[v]=u; 37 return 1; 38 } 39 } 40 } 41 return 0; 42 } 43 44 main() 45 { 46 int t, i, j, k; 47 cin>>t; 48 while(t--){ 49 scanf("%d",&n); 50 for(i=0;i<n;i++){ 51 scanf("%d%s%s%s",&a[i].h,a[i].sex,a[i].music,a[i].sport); 52 } 53 for(i=0;i<=n;i++) ve[i].clear(); 54 for(i=0;i<n;i++){ 55 if(a[i].sex[0]==‘F‘){ 56 for(j=0;j<n;j++){ 57 if(a[j].sex[0]==‘M‘){ 58 if(abs(a[i].h-a[j].h)<=40&&strcmp(a[i].music,a[j].music)==0&&strcmp(a[i].sport,a[j].sport)){ 59 ve[i].push_back(j); 60 } 61 } 62 } 63 } 64 } 65 66 int num=0; 67 memset(from,-1,sizeof(from)); 68 for(i=0;i<n;i++){ 69 memset(visited,false,sizeof(visited)); 70 if(march(i)) num++; 71 } 72 printf("%d\n",n-num); 73 } 74 }
标签:
原文地址:http://www.cnblogs.com/qq1012662902/p/4638512.html