Hdu 4930 斗地主
模拟题,只是想纪念下,WA到死了…… 看到好多代码都好长,其实想说不用这么暴力。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <time.h> using namespace std; const int INF = <<;
const int MAXN = ; char str[][MAXN];
int id[];
int cnt[][MAXN];
int MAX[][];
int tr[][]; bool check() {
int len[] = {strlen(str[]), strlen(str[])};
if (len[]==) return true;
memset(cnt, , sizeof(cnt));
memset(MAX, , sizeof(MAX));
memset(tr, , sizeof(tr)); for (int i = ; i < ; i++) //统计每张牌出现的数量
for (int j = ; j < len[i]; j++)
cnt[i][id[str[i][j]]]++; for (int k = ; k < ; k++) //找出最大的牌
for (int i = ; i > ; i--)
for (int j = ; j > ; j--)
if (cnt[k][j]>=i) {
MAX[k][i] = j;
break;
}
for (int k = ; k < ; k++) //3带1、2
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
if (MAX[k][]> && j!=MAX[k][] && cnt[k][j]>=i)
tr[k][i] = MAX[k][]; if (len[]< && MAX[][len[]]>) return true; //能出完
if (MAX[][]>&&len[]==) return true; //4带2
if ((len[]==&&tr[][]>)||(len[]==&&tr[][]>)) return true; //能出完+1
if (cnt[][]>&&cnt[][]>) return true; //有王炸
if (cnt[][]>&&cnt[][]>) return false; //对方有王炸
if (MAX[][]<MAX[][]) return false; //对方有炸弹 for (int i = ; i > ; i--)
if (MAX[][i]>=MAX[][i] && MAX[][i]>) //有大过对方的牌
return true; return false;
} int main() {
#ifdef Phantom01
freopen("HDU4930.txt", "r", stdin);
#endif //Phantom01 id[''] = ;
id[''] = ;
id[''] = ;
id[''] = ;
id[''] = ;
id[''] = ;
id[''] = ;
id['T'] = ;
id['J'] = ;
id['Q'] = ;
id['K'] = ;
id['A'] = ;
id[''] = ;
id['X'] = ;
id['Y'] = ; int T;
scanf("%d", &T);
gets(str[]); while (T--) {
gets(str[]);
gets(str[]);
if (check()) puts("Yes");
else puts("No");
} return ;
}
Hdu 4930 斗地主的更多相关文章
- hdu 4930 斗地主恶心模拟
http://acm.hdu.edu.cn/showproblem.php?pid=4930 就是两个人玩斗地主,有8种牌型,单张,一对,三张,三带一,三带对,四带二,四炸,王炸.问先手能否一次出完牌 ...
- HDU 4930 Fighting the Landlords(暴力枚举+模拟)
HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...
- HDU 4930 Fighting the Landlords(模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 解题报告:斗地主,加了一个四张可以带两张不一样的牌,也可以带一对,判断打出一手牌之后,如果对手没 ...
- hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...
- 2014多校第六场 1010 || HDU 4930 Fighting the Landlords (模拟)
题目链接 题意 : 玩斗地主,出一把,只要你这一把对方要不了或者你出这一把之后手里没牌了就算你赢. 思路 : 一开始看了第一段以为要出很多次,实际上只问了第一次你能不能赢或者能不能把牌出尽. #inc ...
- HDU 4930 Fighting the Landlords(扯淡模拟题)
Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...
- HDU 4930 Fighting the Landlords --多Trick,较复杂模拟
题意:两个人A和B在打牌,只有题目给出的几种牌能出若A第一次出牌B压不住或者A一次就把牌出完了,那么A赢,输出Yes,否则若A牌没出完而且被B压住了,那么A输,输出No. 解法:知道规则,看清题目,搞 ...
- 2014 HDU多校弟六场J题 【模拟斗地主】
这是一道5Y的题目 有坑的地方我已在代码中注释好了 QAQ Ps:模拟题还是练的太少了,速度不够快诶 //#pragma comment(linker, "/STACK:16777216&q ...
- HDU 1847 Good Luck in CET-4 Everybody!(规律,博弈)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
随机推荐
- swift语言点评十七-Designated Initializers and Convenience Initializers
Swift defines two kinds of initializers for class types to help ensure all stored properties receive ...
- How Javascript works (Javascript工作原理) (六) WebAssembly 对比 JavaScript 及其使用场景
个人总结: 1.webassembly简介:WebAssembly是一种用于开发网络应用的高效,底层的字节码.允许在网络应用中使用除JavaScript的语言以外的语言(比如C,C++,Rust及其他 ...
- Python ftplib 模块关于 ftp的下载
import ftplib import os import socket import sys HOST='192.168.216.193' DIRN='c:\\ftp\FTP.123' FILE= ...
- OpenJDK源码研究笔记(二)-Comparable和Comparator2个接口的作用和区别(一道经典的Java笔试面试题)
Comparable和Comparator是JDK中定义的2个比较接口,很相似,但又有所不同. 这2个接口的作用和区别也是Java中的常见经典面试题. 下面我们就来详细介绍下这2个接口的定义.作用.区 ...
- UI布局【转】
转载自: https://www.cnblogs.com/wangdaijun/p/5519459.html https://www.jianshu.com/p/f781c40df57c Good U ...
- 洛谷 P2747 [USACO5.4]周游加拿大Canada Tour
P2747 [USACO5.4]周游加拿大Canada Tour 题目描述 你赢得了一场航空公司举办的比赛,奖品是一张加拿大环游机票.旅行在这家航空公司开放的最西边的城市开始,然后一直自西向东旅行,直 ...
- Qt之QStackedWidget
简述 QStackedWidget继承自QFrame. QStackedWidget类提供了多页面切换的布局,一次只能看到一个界面. QStackedWidget可用于创建类似于QTabWidget提 ...
- Android基础笔记(十三)- 内容提供者原理和简单使用
为什么要有内容提供者 内容提供者的工作原理 使用内容解析者对内容提供者进行增删改查操作 利用内容提供者和内容解析者备份手机短信 利用内容提供者插入短信 为什么要有内容提供者 内容提供者技术的目的是: ...
- Java - Thinking in Java 第2章 一切都是对象
Java是"纯粹"的面向对象的语言. 操作的标示符是对象的一个引用, new是创建一个对象. 存储位置: 寄存器\堆栈(引用)\堆(new)\常量存储(程序代码内部)\非RAM存储 ...
- 【BZOJ 1660】 [Usaco2006 Nov]Bad Hair Day 乱发节
1660: [Usaco2006 Nov]Bad Hair Day 乱发节 Time Limit: 2 Sec Memory Limit: 64 MB Submit: 678 Solved: 32 ...