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]<B[j])
                    map[j][i]=1;
            }
        }
        memset(link,0,sizeof(link));
        ans=0;
        for(i=1;i<=n;i++)
        {
            memset(v,0,sizeof(v));
            if(dfs(i))
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

给定A,B两组牌,让找出B最多能的多少分

首先对牌的字符串全部转化成十进制数,然后以数字为点,

B集合元素相对于A集合数字的大小关系为边,显然是典型的最小顶点覆盖问题 

时间: 2024-10-07 12:35:29

hdu 1528 Card Game Cheater (最小覆盖)的相关文章

HDU 1528 Card Game Cheater

Card Game Cheater Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at

HDU 1528 Card Game Cheater(打扑克)

Description: Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the cards fa

HDOJ 1528 Card Game Cheater

简单二分图匹配.... Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1073    Accepted Submission(s): 565 Problem Description Adam and Eve play a card game using a regular deck of 52 ca

HDOJ 题目1528 Card Game Cheater(二分图最小点覆盖)

Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1357    Accepted Submission(s): 722 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rul

HDU 1528 (二分图最大匹配 + 最小覆盖, 14.07.17)

Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the c

(hdu step 6.3.5)Card Game Cheater(匹配的最大数:a与b打牌,问b赢a多少次)

称号: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 74   Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules

(hdu step 6.3.5)Card Game Cheater(最大匹配数:a与b打牌,问b能赢a多少次)

题目: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 74   Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules

hdu 6025 card card card(双指针)

题目链接:hdu 6025 card card card 题意: 有n对数(a,b),现在你可以将前x对(a,b)移到尾部. 操作完后,现在定义sum=ai-bi (1,x),当sum<0时,当前的价值为Σai (1<=i<=x-1). 问你移动前多少对(a,b),使得价值最大,如果有多个答案,输出最小的那个. 题解: 复制一份,双指针模拟一下就行了. 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=a;i<

Card Game Cheater(贪心+二分匹配)

Card Game Cheater Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1566    Accepted Submission(s): 822 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rule