标签:return string name pac lse pre size printf maps
#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
#define N 10100
int vis[N], h[N], used[N], maps[1510][1510], n, ans;
int e[N],ne[N],idx;
void add(int a, int b)
{
e[idx]=b;
ne[idx]=h[a];
h[a]=idx++;
}
bool Find(int u)
{
for(int j=h[u]; j!=-1; j=ne[j])
{
int v = e[j];
if(!vis[v])
{
vis[v] = 1;
if(!used[v] || Find(used[v]))
{
used[v] = u;
return true;
}
}
}
return false;
}
int main()
{
int a, b, m;
while(scanf("%d", &n)!=EOF)
{
idx = 0;
memset(h, -1, sizeof(h));
for(int i=0; i<n; i++)
{
scanf("%d:(%d)", &a, &m);
while(m--)
{
scanf("%d", &b);
add(a, b);
add(b, a);
}
}
ans = 0;
memset(used, 0, sizeof(used));
for(int i=0; i<n; i++)
{
memset(vis, 0, sizeof(vis));
if(Find(i))
ans++;
}
printf("%d\n", ans/2);
}
return 0;
}
标签:return string name pac lse pre size printf maps
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12430949.html