标签:des style blog color java os strong io
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 707 Accepted Submission(s): 336
1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <algorithm> 5 #include <iostream> 6 using namespace std; 7 #define N 550 8 9 vector<int>ve[N]; 10 int from[N]; 11 int visited[N]; 12 struct node{ 13 int h, m; 14 int t; 15 int st; 16 int a, b, c, d; 17 }a[N]; 18 19 int march(int u){ 20 int i, v; 21 for(i=0;i<ve[u].size();i++){ 22 v=ve[u][i]; 23 if(!visited[v]){ 24 visited[v]=1; 25 if(from[v]==-1||march(from[v])){ 26 from[v]=u; 27 return 1; 28 } 29 } 30 } 31 return 0; 32 } 33 main() 34 { 35 int i, j, k, num; 36 int n, t; 37 cin>>t; 38 while(t--){ 39 scanf("%d",&n); 40 memset(from,-1,sizeof(from)); 41 for(i=1;i<=n;i++){ 42 ve[i].clear(); 43 scanf("%d:%d %d %d %d %d",&a[i].h,&a[i].m,&a[i].a,&a[i].b,&a[i].c,&a[i].d); 44 a[i].t=a[i].h*60+a[i].m+abs(a[i].a-a[i].c)+abs(a[i].b-a[i].d); 45 a[i].st=a[i].h*60+a[i].m; 46 } 47 for(i=1;i<=n;i++){ 48 for(j=1;j<=n;j++){ 49 if(i!=j&&a[i].t+abs(a[i].c-a[j].a)+abs(a[i].d-a[j].b)<a[j].st){ 50 ve[i].push_back(j); 51 } 52 } 53 } 54 num=0; 55 for(i=1;i<=n;i++){ 56 memset(visited,0,sizeof(visited)); 57 if(march(i)) 58 num++; 59 } 60 printf("%d\n",n-num); 61 } 62 }
HDU 1350 最小路径覆盖,布布扣,bubuko.com
标签:des style blog color java os strong io
原文地址:http://www.cnblogs.com/qq1012662902/p/3886037.html