| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我不知道哪里错了#include<iostream>
#include<cstring>
#include<cstdio>
#define init(x) memset(x,0,sizeof(x))
#define init0xff(x) memset(x,0xff,sizeof(x))
using namespace std;
int c1[301],c2[301];
int g[301][301];
int mk[301];
int n,m;
int path(int u)
{
int v;
for(v = 1; v<= n;v ++)
{
if(g[u][v] == 1 && !mk[v])
{
mk[v] = 1;
if(c2[v] == -1 || path(c2[v]))
{
c1[u] = v;
c2[v] = u;
return 1;
}
}
}
return 0;
}
int MaxMatch()
{
int ret = 0 ,i;
init0xff(c1);
init0xff(c2);
for(i = 1;i <= n;i++)
{
if(c1[i]== -1)
{
//cout <<1 << endl;
init(mk);
if(path(i))
ret ++;
}
}
return ret;
}
int main()
{
int i,x,y,j;
int t,s,num;
scanf("%d",&t);
while(t--)
{
init(g);
scanf("%d%d",&n,&m);
for(i = 1 ;i <= n;i++)
{
scanf("%d",&s);
for(j =1 ;j <= s;j++)
{
scanf("%d",&num);
g[i][num] = 1;
}
}
if(MaxMatch() == n)
{
printf("YES\n");
}
else
printf("NO\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator