这是一道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. feof()和EOF的用法(转载)

    查看 stdio.h 可以看到如下定义: #define  EOF  (-1) #define  _IOEOF  0x0010 #define  feof(_stream)  ((_stream)-& ...

  2. MVC-04 视图(1)

    不可否认的,View应该是整个ASP.NET MVC项目开发过程中最花时间的部分,因为与显示逻辑相关的技术五花八门,你可能要学习的有HTML.CSS.JavaScript.DOM.JQuery.JSO ...

  3. js获取浏览器窗口的大小

    在我本地测试当中: 在IE.FireFox.Opera下都可以使用 document.body.clientWidth document.body.clientHeight 即可获得,很简单,很方便. ...

  4. python的正则表达式 re

    python的正则表达式 re 本模块提供了和Perl里的正则表达式类似的功能,不关是正则表达式本身还是被搜索的字符串,都可以是Unicode字符,这点不用担心,python会处理地和Ascii字符一 ...

  5. javascript 字符串方法传参

    javascript 字符串方法传参由于嵌套的单引号,双引号过多.有点混乱.. 正确方法如下: '   <td align="left"><input type= ...

  6. Score(规律)

    Score Time Limit : 5000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submiss ...

  7. UVA 12230 - Crossing Rivers(概率)

    UVA 12230 - Crossing Rivers 题目链接 题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,如今要求从A到B,所须要的期望时间 思路:每条河的期望,最坏就是船刚开 ...

  8. 工具篇-MAT(Memory Analyzer Tool)

    --- layout: post title: 工具篇-MAT(Memory Analyzer Tool) description: 让内存泄漏无所遁形 2015-10-08 category: bl ...

  9. ThinkPHP - 组织分类结构

  10. 优雅的python

    在知乎上看到的问题--python有哪些优雅的代码实现. 下面的代码大概也算不上优雅. 一下代码在python3中实现 更多内容可见:http://book.pythontips.com/en/lat ...