 #include <iostream>
#include <iostream>
 using namespace std;
using namespace std;
 #define N 301
#define N 301
 #define M 96
#define M 96
 bool map[N][M];
bool map[N][M];
 int match[M];
int match[M];
 bool chk[M];
bool chk[M];
 int n, m=85;
int n, m=85;
 int dfs(int p)
int dfs(int p)


 {
{
 int i,t;
    int i,t;
 for(i=1; i<=m; i++)
    for(i=1; i<=m; i++)

 
     {
{
 if(!chk[i] && map[p][i] )
        if(!chk[i] && map[p][i] )

 
         {
{
 chk[i]=1;
            chk[i]=1;
 t=match[i];
            t=match[i];
 match[i]=p;
            match[i]=p;
 if(t == -1 || dfs(t) ) return 1;
            if(t == -1 || dfs(t) ) return 1;
 match[i]=t;
            match[i]=t;
 }
        }
 }
    }
 return 0;
    return 0;
 }
}
 int maxMah()
int maxMah()


 {
{
 int i, ans=0;
    int i, ans=0;
 for(i=1; i<=n; i++)
    for(i=1; i<=n; i++)

 
     {
{
 memset(chk, 0, sizeof(chk));
        memset(chk, 0, sizeof(chk));
 if(dfs(i)) ans++;
        if(dfs(i)) ans++;
 }
    }
 return ans;
    return ans;
 }
}

 int main()
int main()


 {
{
 int i,j,p,q,t;
    int i,j,p,q,t;

 while(scanf("%d", &n)!=EOF)
    while(scanf("%d", &n)!=EOF)

 
     {
{
 //printf("%d\n",n);
        //printf("%d\n",n);
 memset(map,0, sizeof(map));
        memset(map,0, sizeof(map));
 memset(match, -1, sizeof(match));
        memset(match, -1, sizeof(match));
 for(i=1; i<=n; i++)
        for(i=1; i<=n; i++)

 
         {
{
 //printf("%d\n",i);
            //printf("%d\n",i);
 scanf("%d", &t);
            scanf("%d", &t);
 //printf("%d\n", t);
            //printf("%d\n", t);
 for(j=0; j<t; j++)
            for(j=0; j<t; j++)

 
             {
{
 scanf("%d%d",&p, &q);
                scanf("%d%d",&p, &q);
 map[i][(p-1)*12+q]=1;
                map[i][(p-1)*12+q]=1;
 }
            }
 }
        }
 printf("%d\n",maxMah());
        printf("%d\n",maxMah());
 }
    }
 return 0;
    return 0;
 }
}

posted on 2010-03-25 16:26 
wyiu 阅读(376) 
评论(0)  编辑 收藏 引用  所属分类: 
POJ