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
#define inf 1000000
#define ll int
struct node{
    int a[N];
    int siz, kind;
    void init(int s, int k){memset(a, 0, sizeof a); siz = s;kind = k;}
}x, y, z;

int fuck(char c){
if('3'<=c&&c<='9')return c-'0';
        else if(c=='T')    return 10;
        else if(c=='J')    return 11;
        else if(c=='Q') return 12;
        else if(c=='K') return 13;
        else if(c=='A') return 14;
        else if(c=='2') return 15;
        else if(c=='X') return 16;
        return 17;
}
void go(char *s, node &a){
    memset(a.a, 0, sizeof a.a);
    a.siz = strlen(s);
    for(int i = 0; s[i]; i++)
        a.a[fuck(s[i])] ++;
}
char s[N], t[N], tmp[N];
int top, n, m;

void hav_tmp(int x){
    top = 0;
    int i = 0;
    while(x){
        if(x&1) tmp[top++] = s[i];
        i++;
        x>>=1;
    }
    tmp[top] = 0;
}

bool ok(){
    int kind = x.kind;
    if( kind == 0 )return false;
    if(x.siz == n)return true;
    if(y.a[16] && y.a[17]) return false;
    if(kind != 9 && kind != 6) {
        for(int i = 15; i >= 3; i--)
            if(y.a[i] == 4)return false;
    }
    if(kind <= 3 || kind == 9) {
        int yi;
        for(int i = 17; i >= 3; i--)if(x.a[i]){yi = i;break;}
        for(int i = 17; i > yi; i--)
            if(y.a[i] >= kind || y.a[i] == 4)return false;
        return true;
    }
    if(y.siz < kind)return false;
    if(kind == 6) {
        int si ;
        for(int i = 15 ; i>=3; i--)if(x.a[i]==4)si = i;
        for(int i = 15; i > si; i--)if(y.a[i]==4)return false;
        return true;
    }

    int san;
    for(int i = 15; i >= 3; i--)if(x.a[i]==3)san = i;
    for(int i = 15; i > san; i--)if(y.a[i]>=3)
        return false;
    return true;
}
bool work(){
    for(int i = 17; i >= 3; i--)if(z.a[i])
    {
        x.init(1,1); x.a[i]++;
        if(ok())return true;
        break;
    }
    for(int i = 17; i >= 3; i--)if(z.a[i]==2){
        x.init(2,2); x.a[i]=2;
        if(ok())return true;
        break;
    }
    for(int i = 17; i >= 3; i--)if(z.a[i]==3){
        x.init(3,3); x.a[i]=3;
        if(ok())return true;
        if(z.siz >= 4){
            x.init(4,4);
            x.a[i]=3;
            x.a[i+1] = 1;
            if(ok())return true;
        }
        if(z.siz >= 5){
            x.init(5,5);
            x.a[i]=3;
            x.a[i+1] = 2;
            if(ok())return true;
        }
        break;
    }
    for(int i = 17; i >= 3; i--)if(z.a[i]==4){
        x.init(4,9); x.a[i]=4;
        if(ok())return true;
        if(z.siz >= 6){
            x.init(6, 6);
            x.a[i]=4;
            x.a[i+1] = 2;
            if(ok())return true;
        }
        break;
    }
    return false;
}

int main(){
    int T; cin>>T;
    while(T--){
        scanf("%s",s);
        scanf("%s",t);
        n = strlen(s); m = strlen(t);
        go(t, y);
        go(s, z);
        if(z.a[16] && z.a[17]){puts("Yes");continue;}

        work() ? puts("Yes"):puts("No");
    }
    return 0;
}
/*
99
33A
2
33A
22
33
22
5559T
9993

555
3333

55522
3333

555777
3333

35
7

39
7

XY
2222AAAA

Y
K

22
AA3333

222
AA3333

3333
XY

333342
XY

*/

HDU 4930 Fighting the Landlords 模拟,布布扣,bubuko.com

时间: 2024-08-07 08:29:09

HDU 4930 Fighting the Landlords 模拟的相关文章

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(扯淡模拟题)

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.

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(模拟)

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

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

HDU4930 Fighting the Landlords 模拟

Fighting the Landlords Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 175    Accepted Submission(s): 61 Problem Description Fighting the Landlords is a card game which