POJ 2062 HDU 1528 ZOJ 2223 Card Game Cheater

水题,感觉和田忌赛马差不多

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

struct P1
{
    int Num;
    int Hua;
} Play1[30];

struct P2
{
    int Num;
    int Hua;
} Play2[30];

bool cmp1(const P1&a,const P1&b)
{
    if(a.Num==b.Num) return a.Hua<b.Hua;
    return a.Num<b.Num;
}
bool cmp2(const P2&a,const P2&b)
{
    if(a.Num==b.Num) return a.Hua<b.Hua;
    return a.Num<b.Num;
}

int main()
{
    int n;
    int i,j;
    char s[5];
    int TT;
    scanf("%d",&TT);
    while(TT--)
    {
        scanf("%d",&n);
        for(i=0; i<n; i++)
        {
            scanf("%s",s);
            int num,hua;
            if(s[0]>=‘0‘&&s[0]<=‘9‘) num=s[0]-‘0‘;
            if(s[0]==‘T‘) num=10;
            if(s[0]==‘J‘) num=11;
            if(s[0]==‘Q‘) num=12;
            if(s[0]==‘K‘) num=13;
            if(s[0]==‘A‘) num=14;
            Play1[i].Num=num;
            if(s[1]==‘C‘) hua=1;
            if(s[1]==‘D‘) hua=2;
            if(s[1]==‘S‘) hua=3;
            if(s[1]==‘H‘) hua=4;
            Play1[i].Hua=hua;
        }
        sort(Play1,Play1+n,cmp1);
        for(i=0; i<n; i++)
        {
            scanf("%s",s);
            int num,hua;
            if(s[0]>=‘0‘&&s[0]<=‘9‘) num=s[0]-‘0‘;
            if(s[0]==‘T‘) num=10;
            if(s[0]==‘J‘) num=11;
            if(s[0]==‘Q‘) num=12;
            if(s[0]==‘K‘) num=13;
            if(s[0]==‘A‘) num=14;
            Play2[i].Num=num;
            if(s[1]==‘C‘) hua=1;
            if(s[1]==‘D‘) hua=2;
            if(s[1]==‘S‘) hua=3;
            if(s[1]==‘H‘) hua=4;
            Play2[i].Hua=hua;
        }
        sort(Play2,Play2+n,cmp2);
        int ans=0;
        int P=0;
        for(i=0; i<n; i++)
        {
            for(j=P; j<n; j++)
            {
                if((Play2[j].Num>Play1[i].Num)||(Play2[j].Num==Play1[i].Num&&Play2[j].Hua>Play1[i].Hua))
                {
                    ans++;

                    P=j+1;break;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
时间: 2024-12-05 16:32:31

POJ 2062 HDU 1528 ZOJ 2223 Card Game Cheater的相关文章

POJ 1071 &amp; HDU 1364 &amp; ZOJ 1019 Illusive Chase(DFS)

题目链接: POJ:http://poj.org/problem?id=1071 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1364 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=19 Description Tom the robocat is presented in a Robotics Exhibition for an enthusiastic audien

poj 1543 &amp; HDU 1334 &amp; ZOJ 1331 Perfect Cubes(数学 暴力大法好)

题目链接:http://poj.org/problem?id=1543 Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that a^n = b^n + c^n, has remained elusively unproven. (A recent proof is believ

uva 10129 poj 1386 hdu 1116 zoj 2016 play on words

//本来是想练一下欧拉回路的,结果紫书上那题是大水题!!!!! 题意:给出n个单词,是否可以把单词排列成每个单词的第一个字母和上一个单词的最后一个字母相同 解:欧拉通路存在=底图联通+初度!=入度的点至多只有两个(分别为入点和出点) 1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<algorithm> 5 #include<cstring> 6 #inclu

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

POJ1607 &amp; HDU 1330 &amp; ZOJ 1216 Deck(数学题)

题目链接: POJ  1607 : http://poj.org/problem?id=1607 HDU 1330 :http://acm.hdu.edu.cn/showproblem.php?pid=1330 ZOJ  1216 : Description A single playing card can be placed on a table, carefully, so that the short edges of the card are parallel to the table

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

POJ 2411 &amp;&amp; HDU 1400 Mondriaan&#39;s Dream (状压dp 经典题)

Mondriaan's Dream Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 12341   Accepted: 7204 Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series

HDU 1986 &amp; ZOJ 2989 Encoding(模拟)

题目链接: HDU: http://acm.hdu.edu.cn/showproblem.php?pid=1986 ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1988 HDU 1987 & ZOJ 2990 和这题刚好相反,也是比较容易模拟: Chip and Dale have devised an encryption method to hide their (written) text messages

poj 1226 hdu 1238 Substrings 求若干字符串正串及反串的最长公共子串 2002亚洲赛天津预选题

题目:http://poj.org/problem?id=1226 http://acm.hdu.edu.cn/showproblem.php?pid=1238 其实用hash+lcp可能也可以,甚至可能写起来更快,不过我没试,我最近在练习后缀数组,所以来练手 后缀数组的典型用法之一----------------后缀数组+lcp+二分 思路:1.首先将所有的字符串每读取一个,就将其反转,作为一组,假设其下标为i到j,那么cnt[i]到cnt[j]都标记为一个数字(这个数字意思是第几个读入的字符