HDU 4930 Fighting the Landlords(扯淡模拟题)

Fighting the Landlords

大意:

斗地主。。。。   分别给出两把手牌,肯定都合法。每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3。

给你8种组合:1.单牌:一张牌

        2.对子:两张相同的牌

        3.三重奏(百度翻译出来的。。):三张相同的牌

        4.三带一:三张相同的带一张牌(大小只考虑前面的牌,不考虑带的)

        5.三带二:三张相同的带两张牌,带的两张牌可以一样,也可以不一样(大小只考虑前面的牌,不考虑带的)

        6.四带二:四个相同的带两张牌,带的两张牌可以一样,也可以不一样(大小只考虑前面的牌,不考虑带的)

        7.炸弹:四个相同的一起出,不带任何东西(能管除了核弹所有的)

        8.核弹:大小王一起(能管所有的牌)

然后规则其实很简单,就是你先出,如果你出了之后,手牌没有了,输出Yes,或者你出了之后,对方没有比你出的这一把大的,也输出Yes,剩下就是输出No了。。。

思路:

比赛的时候一直卡1007,T到死。。。。也没来的及管这个题。。其实不难。。

主要注意几个坑的地方就行:

1.不能四带一。

2.炸弹可以干掉四带二

3.理解好题意什么时候输出Yes

发这篇博客的目的不是粘代码,代码写的实在是太挫了。。。。 要看的话只看题目描述吧。。。。就是想记录一下这个题-。-
 我好无聊~

#include <stdio.h>
#include <string.h>

int Hash1[20], Hash2[20];
int T;
char s1[20], s2[20];

int main()
{
    scanf("%d", &T);
    while(T--){
        memset(Hash1, 0, sizeof(Hash1));
        memset(Hash2, 0, sizeof(Hash2));
        scanf("%s", s1);
        int len1 = strlen(s1);
        for(int i = 0; i < len1; ++i){
            if(s1[i] >= '3' && s1[i] <= '9'){
                Hash1[s1[i]-'0']++;
            }
            else if(s1[i] == 'T'){
                Hash1[10]++;
            }
            else if(s1[i] == 'J'){
                Hash1[11]++;
            }
            else if(s1[i] == 'Q'){
                Hash1[12]++;
            }
            else if(s1[i] == 'K'){
                Hash1[13]++;
            }
            else if(s1[i] == 'A'){
                Hash1[14]++;
            }
            else if(s1[i] == '2'){
                Hash1[15]++;
            }
            else if(s1[i] == 'X'){
                Hash1[16]++;
            }
            else if(s1[i] == 'Y'){
                Hash1[17]++;
            }
        }
//        for(int i = 3; i <= 17; ++i){
//            printf("%d ", Hash1[i]);
//        }
        scanf("%s", s2);
        int len2 = strlen(s2);
        for(int i = 0; i < len2; ++i){
            if(s2[i] >= '3' && s2[i] <= '9'){
                Hash2[s2[i]-'0']++;
            }
            else if(s2[i] == 'T'){
                Hash2[10]++;
            }
            else if(s2[i] == 'J'){
                Hash2[11]++;
            }
            else if(s2[i] == 'Q'){
                Hash2[12]++;
            }
            else if(s2[i] == 'K'){
                Hash2[13]++;
            }
            else if(s2[i] == 'A'){
                Hash2[14]++;
            }
            else if(s2[i] == '2'){
                Hash2[15]++;
            }
            else if(s2[i] == 'X'){
                Hash2[16]++;
            }
            else if(s2[i] == 'Y'){
                Hash2[17]++;
            }
        }
//        for(int i = 3; i <= 17; ++i){
//            printf("%d ", Hash2[i]);
//        }
        if(Hash1[16] == 1 && Hash1[17] == 1){
            printf("Yes\n");
            continue;
        }

        ///clear
        int cnt = 0;
        for(int i = 3; i <= 17; ++i){
            if(Hash1[i] > 0){
                cnt++;
            }
        }
        if(cnt == 1){
            printf("Yes\n");
            continue;
        }
        else if(cnt == 2){
            int t1 = 0, t2 = 0;
            for(int i = 3; i <= 17; ++i){
                if(Hash1[i] > 0){
                    if(t1 == 0){
                        t1 = i;
                    }
                    else {
                        t2 = i;
                    }
                }
            }
            if(Hash1[t1] == 3 && Hash1[t2] == 1){
                printf("Yes\n");
                continue;
            }
            if(Hash1[t2] == 3 && Hash1[t1] == 1){
                printf("Yes\n");
                continue;
            }
            if(Hash1[t1] == 3 && Hash1[t2] == 2){
                printf("Yes\n");
                continue;
            }
            if(Hash1[t2] == 3 && Hash1[t1] == 2){
                printf("Yes\n");
                continue;
            }
            if(Hash1[t1] == 4 && Hash1[t2] == 2){
                printf("Yes\n");
                continue;
            }
            if(Hash1[t2] == 4 && Hash1[t1] == 2){
                printf("Yes\n");
                continue;
            }
        }
        else if(cnt == 3){
            int t1 = 0, t2 = 0, t3 = 0;
            for(int i = 3; i <= 17; ++i){
                if(Hash1[i] > 0){
                    if(t1 == 0){
                        t1 = i;
                    }
                    else if(t2 == 0){
                        t2 = i;
                    }
                    else {
                        t3 = i;
                    }
                }
            }
            if(Hash1[t1] == 4 && Hash1[t2] == 1 && Hash1[t3] == 1){
                printf("Yes\n");
                continue;
            }
            else if(Hash1[t1] == 1 && Hash1[t2] == 4 && Hash1[t3] == 1){
                printf("Yes\n");
                continue;
            }
            else if(Hash1[t1] == 1 && Hash1[t2] == 1 && Hash1[t3] == 4){
                printf("Yes\n");
                continue;
            }
        }

        if(Hash2[16] == 1 && Hash2[17] == 1){
            printf("No\n");
            continue;
        }

        bool flag = false;
        ///bomb
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 4){
                int j;
                for(j = i+1; j <= 15; ++j){
                    if(Hash2[j] == 4){
                        break;
                    }
                }
                if(j == 16){
                    flag = true;
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Four-Dual
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 4 && len1 >= 6){
                int j;
                for(j = i+1; j <= 15; ++j){
                    if(Hash2[j] == 4 && len2 >= 6){
                        break;
                    }
                }
                int k;
                for(k = 3; k <= 15; ++k){
                    if(Hash2[k] == 4){
                        break;
                    }
                }
                if(j == 16 && k == 16){
                    flag = true;
                    //printf("Four-Dual\n");
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Trio-Pair
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 3){
                for(int j = 3; j <= 15; ++j){
                    if(Hash1[j] == 2){
                        int k;
                        int t = 0;
                        for(k = i+1; k <= 15; ++k){
                            if(Hash2[k] == 3){
                                for(int l = 3; l <= 15; ++l){
                                    if(Hash2[l] == 2){
                                        t = 1;
                                        break;
                                    }
                                }
                                if(t == 1){
                                    break;
                                }
                            }
                        }
                        int p;
                        for(p = 3; p <= 15; ++p){
                            if(Hash2[p] == 4){
                                break;
                            }
                        }
                        if(k == 16 && p == 16){
                            flag = true;
                            //printf("Trio-Pair\n");
                        }
                    }
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Trio-Solo
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 3 && len1 >= 4){
                int j;
                for(j = i+1; j <= 15; ++j){
                    if(Hash2[j] == 3 && len2 >= 4){
                        break;
                    }
                }
                int k;
                for(k = 3; k <= 15; ++k){
                    if(Hash2[k] == 4){
                        break;
                    }
                }
                if(j == 16 && k == 16){
                    flag = true;
                    //printf("Trio-Solo\n");
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Trio
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 3){
                int j;
                for(j = i+1; j <= 15; ++j){
                    if(Hash2[j] >= 3){
                        break;
                    }
                }
                int k;
                for(k = 3; k <= 15; ++k){
                    if(Hash2[k] == 4){
                        break;
                    }
                }
                if(j == 16 && k == 16){
                    flag = true;
                    //printf("Trio\n");
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Pair
        for(int i = 15; i >= 3; --i){
            if(Hash1[i] == 2){
                int j;
                for(j = i+1; j <= 15; ++j){
                    if(Hash2[j] >= 2){
                        break;
                    }
                }
                int k;
                for(k = 3; k <= 15; ++k){
                    if(Hash2[k] == 4){
                        break;
                    }
                }
                if(j == 16 && k == 16){
                    flag = true;
                    //printf("Pair\n");
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }

        ///Solo
        for(int i = 17; i >= 3; --i){
            if(Hash1[i] == 1){
                int j;
                for(j = i+1; j <= 17; ++j){
                    if(Hash2[j] >= 1){
                        break;
                    }
                }
                int k;
                for(k = 3; k <= 15; ++k){
                    if(Hash2[k] == 4){
                        break;
                    }
                }
                if(j == 18 && k == 16){
                    flag = true;
                    //printf("Solo\n");
                }
            }
        }
        if(flag){
            printf("Yes\n");
            continue;
        }
        printf("No\n");
    }

    return 0;
}

HDU 4930 Fighting the Landlords(扯淡模拟题),布布扣,bubuko.com

时间: 2024-07-30 10:18:39

HDU 4930 Fighting the Landlords(扯淡模拟题)的相关文章

HDU 4930 Fighting the Landlords(暴力枚举+模拟)

HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型,如果先手能一步走完,或者一步让后手无法管上,就赢 思路:先枚举出两个人所有可能的牌型的最大值,然后再去判断即可 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct Player { int rank[15]; } p1, p2; int t, h

hdu 4930 Fighting the Landlords (模拟)

Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 160    Accepted Submission(s): 52 Problem Description Fighting the Landlords is a card game which has been a heat for ye

HDU 4930 Fighting the Landlords(模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 解题报告:斗地主,加了一个四张可以带两张不一样的牌,也可以带一对,判断打出一手牌之后,如果对手没有能够大过你的牌就输出Yes,或者如果你把手上的牌一次性打完也输出Yes,否则输出No,代码有280多行,表示光是敲代码就花了一个多小时,手速还是太慢. 1.首先判断手上的牌能不能一次打完 如果一次性打不完: 2.首先判断对方有没有一对王,有就输出No 3.判断对手有没有四张的牌,如果有,再判断自己

HDU 4930 Fighting the Landlords 模拟

_(:зゝ∠)_ 4带2居然不是炸弹,, #include <algorithm> #include <cctype> #include <cassert> #include <cstdio> #include <cstring> #include <climits> #include <vector> #include<iostream> using namespace std; #define N 18 #

HDU 4930 Fighting the Landlords --多Trick,较复杂模拟

题意:两个人A和B在打牌,只有题目给出的几种牌能出若A第一次出牌B压不住或者A一次就把牌出完了,那么A赢,输出Yes,否则若A牌没出完而且被B压住了,那么A输,输出No. 解法:知道规则,看清题目,搞清有哪些Trick,就可以直接模拟搞了.详见代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #inclu

2014多校第六场 1010 || HDU 4930 Fighting the Landlords (模拟)

题目链接 题意 : 玩斗地主,出一把,只要你这一把对方要不了或者你出这一把之后手里没牌了就算你赢. 思路 : 一开始看了第一段以为要出很多次,实际上只问了第一次你能不能赢或者能不能把牌出尽. 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 5 using namespace std ; 6 7 char str1[20],str2[20] ; 8 int hash1[20],hash2[2

hdu 4930 Fighting the Landlords

Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 480    Accepted Submission(s): 163 Problem Description Fighting the Landlords is a card game which has been a heat for y

HDU 4930 Fighting the Landlords (超级暴力+读懂题意)

题目链接:HDU 4930 Fighting the Landlords 斗地主!!.不会玩这游戏,真是苦逼.题意其他都还好,就是要注意只要第一个回合1号玩家能压制2号玩家就算赢了(突破点). 其他就分类暴力了,思路还是比较清晰的. 注意点: 1.对方炸弹,必输 2.一回合就出完牌,必胜 AC代码: #include<stdio.h> #include<string.h> int vis1[30],vis2[30]; int find(char s) { if(s=='T') re

hdu 5641 King&#39;s Phone(暴力模拟题)

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as