这是一道5Y的题目

有坑的地方我已在代码中注释好了 QAQ

Ps:模拟题还是练的太少了,速度不够快诶

//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std; const int INF = 0x3f3f3f3f;
const int MAXN = ; char array_a[], array_b[];
int store_a[], store_b[];
char rules[];
bool ans; int find_rank(char num){
for(int i = ; i <= ; ++i){
if(rules[i] == num){
return i;
}
}
} void init(){
ans = false;
rules[] = '', rules[] = '', rules[] = '', rules[] = '';
rules[] = '', rules[] = '', rules[] = '', rules[] = 'T';
rules[] = 'J', rules[] = 'Q', rules[] = 'K', rules[] = 'A';
rules[] = '', rules[] = 'X', rules[] = 'Y'; memset(store_a, , sizeof(store_a));
memset(store_b, , sizeof(store_b));
for(int i = ; i < strlen(array_a); ++i)
++store_a[find_rank(array_a[i])];
for(int i = ; i < strlen(array_b); ++i)
++store_b[find_rank(array_b[i])];
} bool lose(){
int i, j;
if(store_b[] == && store_b[] == ) return true;
for(i = ; i <= ; ++i)
if(store_b[i] == ) return true;
return false;
} bool way_2(){
int i, j;
int get_a_max, get_b_max;
if(lose()) return false;
for(i = ; i >= ; --i){
if(store_a[i]){
get_a_max = i;
break;
}
}
for(i = ; i >= ; --i){
if(store_b[i]){
get_b_max = i;
break;
}
}
if(get_a_max >= get_b_max) return true;
return false;
} bool way_3(){
int i, j;
if(store_a[] == && store_a[] == ) return true;
if(way_2()) return true;
if(lose()) return false;
int get_a_max, get_b_max;
get_a_max = get_b_max = ;//get_*_max init 0
for(i = ; i >= ; --i){
if(store_a[i] == ){
get_a_max = i;
break;
}
}
for(i = ; i >= ; --i){
if(store_b[i] == ){
get_b_max = i;
break;
}
}
if(get_a_max == ) return false;//if get_*_max is still 0 , return false
else if(get_a_max >= get_b_max) return true;
return false;
} bool way_4(){
int i, j;
if(way_3()) return true;
if(lose()) return false; int get_a_max, get_b_max;
get_a_max = get_b_max = ;//
for(i = ; i >= ; --i){
if(store_a[i] == ){
get_a_max = i;
break;
}
}
for(i = ; i >= ; --i){
if(store_b[i] == ){
get_b_max = i;
break;
}
}
if(get_a_max == ) return false;//
else if(get_a_max >= get_b_max) return true;
return false;
} bool way_5(){
int i, j;
if(way_4()) return true;
if(store_b[] == && store_b[] == ) return false; int num_a = , num_b = ;
for(i = ; i <= ; ++i){
if(store_a[i] >= ){
num_a = i;
break;
}
}
for(i = ; i <= ; ++i){
if(store_b[i] >= ){
num_b = i;
break;
}
}
if(num_a == ) return false;
else if(num_a >= num_b) return true;
return false;
} bool way_6(){
int i, j;
if(way_5()) return true;
if(store_b[] == && store_b[] == ) return false; return false;
} bool first_out(){
int count = ;
int i, j, k;
for(i = ; i <= ; ++i){
if(store_a[i]) count += store_a[i];
}
if( == count){
return true;
} else if( == count){
return true;
} else if( == count){
if(store_a[] == && store_a[] == ){
return true;
} else{
for(i = ; i <= ; ++i){
if(store_a[i] == ){
return true;
}
} if(way_2()) return true;
return false;
}
} else if( == count){
for(i = ; i <= ; ++i){
if(store_a[i] == ){
return true;
}
} if(way_3()) return true;
return false;
} else if( == count){
for(i = ; i <= ; ++i){
if(store_a[i] >= ){
return true;
}
} if(way_4()) return true;
return false;
} else if( == count){
int count_a = , count_b = ;
for(i = ; i <= ; ++i){
if(store_a[i] == ) ++count_a;
else if(store_a[i] == && i <= ) ++count_b;
}
if(count_a && count_b){
return true;
} if(way_5()) return true;//
return false;
} else if( == count){
int count_a = ;
for(i = ; i <= ; ++i){
if(store_a[i] == ) ++count_a;
}
if(count_a){
return true;
} if(way_6()) return true;//
return false;
} if(way_6()) return true;
return false;
} void debug(){
for(int i = ; i <= ; ++i){
printf("%-2d", store_a[i]);
}
printf("\n");
for(int i = ; i <= ; ++i){
printf("%-2d", store_b[i]);
}
printf("\n");
} int main(){
int i, j, k, numCase;
scanf("%d",&numCase);
while(numCase--){
scanf("%s",array_a);
scanf("%s",array_b);
init();
//debug();
if(first_out()){
printf("Yes\n");
} else{
printf("No\n");
}
}
return ;
}

2014 HDU多校弟六场J题 【模拟斗地主】的更多相关文章

  1. 2014 HDU多校弟五场J题 【矩阵乘积】

    题意很简单,就是两个大矩阵相乘,然后求乘积. 用 Strassen算法 的话,当N的规模达到100左右就会StackOverFlow了 况且输入的数据范围可达到800,如果变量还不用全局变量的话连内存 ...

  2. 2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题

    听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到10 ...

  3. 2014 HDU多校弟五场A题 【归并排序求逆序对】

    这题是2Y,第一次WA贡献给了没有long long 的答案QAQ 题意不难理解,解题方法不难. 先用归并排序求出原串中逆序对的个数然后拿来减去k即可,如果答案小于0,则取0 学习了归并排序求逆序对的 ...

  4. 2014 HDU多校弟八场H题 【找规律把】

    看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决, ...

  5. HDU 4923 Room and Moor (多校第六场C题) 单调栈

    Problem Description PM Room defines a sequence A = {A1, A2,..., AN}, each of which is either 0 or 1. ...

  6. 牛客2018多校第六场 J Heritage of skywalkert - nth_element

    传送门 题意:提供一个随机生成函数,让你生成n个数,然后问你其中能找到的两个数的最小公倍数 最大 是多少. 思路:可以用nth_element()函数在O(n)下求出前 15 个大的数(当然,100个 ...

  7. 牛客多校第六场 J Heritage of skywalkert 随即互质概率 nth_element(求最大多少项模板)

    链接:https://www.nowcoder.com/acm/contest/144/J来源:牛客网 skywalkert, the new legend of Beihang University ...

  8. hdu多校第六场1005 (hdu6638) Snowy Smilel 线段树/区间最大和

    题意: 给定一个矩阵,矩阵上有若干点,每个点有正或负的权值,找一个方框框住一些点使得方框中点权值最大. 题解: 离散化横纵坐标,容易将这个问题转化为在矩阵上求最大和子矩阵的问题. 普通的n*n的矩阵的 ...

  9. 2019 牛客多校第六场 J Upgrading Technology

    题目链接:https://ac.nowcoder.com/acm/contest/886/J 题目大意 略. 分析 见代码. 代码如下 #include <bits/stdc++.h> u ...

随机推荐

  1. win7下文件名不能定义为con(任何文件格式)

    从linux传输压缩包到win7下解压缩,总是提示出错,可是在linux下解压都很正常,于是定位出错的文件,发现是con.c和con.h文件,经排查,原因如下: CON是DOS下的特殊设备名 如下由系 ...

  2. (C#)Windows Shell 编程系列2 - 解释,从“桌面”开始展开

    原文 (C#)Windows Shell 编程系列2 - 解释,从“桌面”开始展开 (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢-) 接上一篇:(C#)Windows Shell 编 ...

  3. [置顶] MongoDB 分布式操作——分片操作

    MongoDB 分布式操作——分片操作 描述: 像其它分布式数据库一样,MongoDB同样支持分布式操作,且MongoDB将分布式已经集成到数据库中,其分布式体系如下图所示: 所谓的片,其实就是一个单 ...

  4. 基于Visual C++2013拆解世界五百强面试题--题9-找出所有的排列方式

    给出一个函数来输出一个字符串的所有排列 按照排列组合的知识我们知道 N个字符排列组合个数有n!种, 那么可知f(n) = n*f(n-1), 如果{1,2}的组合有两种,12,21, 那么{123}的 ...

  5. 设计模式 - 适配器模式(adapter pattern) 具体解释

    适配器模式(adapter pattern) 详细解释 本文地址: http://blog.csdn.net/caroline_wendy 适配器模式(adapter pattern): 将一个类的接 ...

  6. Ext JS学习第十五天 Ext基础之 Ext.DomQuery

    此文同来记录学习笔记 •Ext.dom.Query 嗯,这个类一看就是到时做什么事儿的,不用我去过多的解释了.这个类一共提供了8个方法供开发人员去使用. •要说最常用的方法,无非就是Ext.query ...

  7. javascript类型转换、运算符、语句

    1.类型转换: 分为自动转换和强制转换,一般用强制转换. 其他类型转换为整数:parseint(): 其他类型转换为小数:parsefloat(): 判断是否是一个合法的数字类型:isNaN(): 是 ...

  8. 通过SSIS监控远程服务器磁盘空间并发送邮件报警

    本文直接参考了博客园软件人生的文章操作的,写在这里只为做个记录. 到公司这边先把两个报表服务器接收了. 为防止宕机,部署个磁盘警告的SSIS包. Step 1 建立两个变量来接收和写入磁盘容量 Ste ...

  9. [LeetCode]题解(python):012-Integer to Roman

    题目来源: https://leetcode.com/problems/integer-to-roman/ 题意分析: 这道题是要把在区间[1-3999]的数字转化成罗马数字. 题目思路: 只要知道了 ...

  10. poj 1430 第二类斯特林数

    1 #include <iostream> #include <cmath> #include <algorithm> using namespace std; i ...