HDU 1528 Card Game cheater (minimum coverage)

Source: Internet
Author: User

#include "stdio.h" #include "string.h" #define N 52int 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集合数字的大小关系为边,显然是典型的最小顶点覆盖问题 

HDU 1528 Card Game cheater (minimum coverage)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.