hdu 1528 Card Game Cheater (最小覆蓋)
#include"stdio.h"
#include"string.h"
#define N 52
int map[N][N],v[N],link[N];
int A[N],B[N],t,n;
int dfs(int k)
{
int i;
for(i=1;i<=n;i++)
{
if(map[k][i]&&!v[i])
{
v[i]=1;
if(link[i]==0||dfs(link[i]))
{
link[i]=k;
return 1;
}
}
}
return 0;
}
int main()
{
char c,d,e;
int i,j,vv,flag,ans;
int ap,bp;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
getchar();
flag=1;
ap=bp=0;
for(i=0;i<2*n;i++)
{
scanf("%c%c%c",&c,&d,&e);
if(c>='0'&&c<='9')
vv=c-'0';
if(c=='T')vv=10;
if(c=='J')vv=11;
if(c=='Q')vv=12;
if(c=='K')vv=13;
if(c=='A')vv=14;
vv*=100;
if(d=='H')vv+=4;
if(d=='S')vv+=3;
if(d=='D')vv+=2;
if(d=='C')vv+=1;
if(flag)
A[++ap]=vv;
else
B[++bp]=vv;
if(e=='\n')
flag=0;
}
memset(map,0,sizeof(map));
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(A[i]