这是一道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. hdu 4638 Group 莫队算法

    题目链接 很裸的莫队, 就不多说了... #include<bits/stdc++.h> using namespace std; #define pb(x) push_back(x) # ...

  2. json对象的封装与解析

    一.解析json对象 表结构信息对象,json格式,名称为tableObj   *  {   *   "tableName":"t_res",          ...

  3. HDU 1720 A+B Coming

    #include <string> #include <cstdio> #include <iostream> using namespace std; int c ...

  4. SVN同步出现故障

    1.错误描写叙述    同步SVNStatusSubscribe时报告了错误,1中的0个资源已经同步    同步/frame时错误发生:Error getting status for resourc ...

  5. 淘特房产CMS系统 7.5

    资源描写叙述: 淘特房产CMS系统採用淘特AspCms开发,全部前台信息生成静态HTM,提供了楼盘.二手房.房产中介.房产经济人.业主社区等管理模块,集成了淘特CMS与动网论坛,Discuz,Oblo ...

  6. Backbone入门教程

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  7. ajax 基础

    <html><head><script type="text/javascript">function showHint(str){var xm ...

  8. Android滑动事件冲突

    首先,我们假设这样一个场景:一个ViewPager里面嵌套一个ViewPager,内部滑动方向和外部滑动方向一样时,该怎么解决这一冲突呢? 针对滑动冲突这里给出两种解决方案:外部拦截法,内部拦截法. ...

  9. 使用RadioGroup与RadioButton实现多选一

    RadioGroup是RadioButton的集合, RadioGroup里面可以包含很多RadioButton,提供多选一机制,只能选择其中一个 RadioGroup的orientation(方向) ...

  10. shell:监控进程运行状态并自动重启进程

    #!/bin/sh MAXRSTCOUNT=; PROCTOGO=/mnt/hgfs/code/test/show #count is the counter of test started time ...