markdown 在线制作ppt json校验和格式化工具

POJ 1469

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include <string.h>
 4 #include <vector>
 5 #define MAXN 300
 6 #define _clr(x) memset(x,0xff,sizeof(int)*MAXN)
 7 using namespace std;
 8 
 9 int hungary(int m,int n,int mat[][MAXN],int* match1,int* match2);
10 int _m[101][300];
11 int match1[MAXN];
12 int match2[MAXN];
13 int main()
14 {
15     //freopen("acm.acm","r",stdin);
16     int M;
17     int N;
18     int n;
19     int i;
20     int j;
21     int ans;
22     int s;
23     int tem;
24     int num;
25     scanf("%d",&num);
26     while(num --)
27     {
28     scanf("%d%d",&M,&N);
29     memset(_m,0,sizeof(_m));
30     for(i = 0; i < M; ++ i)
31     {
32         scanf("%d",&s);
33         for(j = 0; j < s; ++ j)
34         {
35                 scanf("%d",&n);
36                 _m[i][n-1] = 1;
37         }
38     }
39         ans = hungary(M,N,_m,match1,match2);
40         if(ans == M)
41             printf("YES\n");
42         else
43             printf("NO\n");
44     }
45 }
46 
47 
48 int hungary(int m,int n,int mat[][MAXN],int * match1,int* match2){
49     int s[MAXN],t[MAXN],p,q,ret=0,i,j,k;
50     for (_clr(match1),_clr(match2),i=0;i<m;ret+=(match1[i++]>=0))
51         for (_clr(t),s[p=q=0]=i;p<=q&&match1[i]<0;p++)
52             for (k=s[p],j=0;j<n&&match1[i]<0;j++)
53                 if (mat[k][j]&&t[j]<0){
54                     s[++q]=match2[j],t[j]=k;
55                     if (s[q]<0)
56                         for (p=j;p>=0;j=p)
57                             match2[j]=k=t[j],p=match1[k],match1[k]=j;
58                 }
59     return ret;
60 }

 

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

技术网站地址: vmfor.com

posted @ 2015-06-09 14:04  GavinHacker  阅读(190)  评论(0编辑  收藏  举报
markdown 在线制作ppt json校验和格式化工具