2014 HDU多校弟六场J题 【模拟斗地主】
这是一道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题 【模拟斗地主】的更多相关文章
- 2014 HDU多校弟五场J题 【矩阵乘积】
题意很简单,就是两个大矩阵相乘,然后求乘积. 用 Strassen算法 的话,当N的规模达到100左右就会StackOverFlow了 况且输入的数据范围可达到800,如果变量还不用全局变量的话连内存 ...
- 2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题
听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到10 ...
- 2014 HDU多校弟五场A题 【归并排序求逆序对】
这题是2Y,第一次WA贡献给了没有long long 的答案QAQ 题意不难理解,解题方法不难. 先用归并排序求出原串中逆序对的个数然后拿来减去k即可,如果答案小于0,则取0 学习了归并排序求逆序对的 ...
- 2014 HDU多校弟八场H题 【找规律把】
看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决, ...
- 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. ...
- 牛客2018多校第六场 J Heritage of skywalkert - nth_element
传送门 题意:提供一个随机生成函数,让你生成n个数,然后问你其中能找到的两个数的最小公倍数 最大 是多少. 思路:可以用nth_element()函数在O(n)下求出前 15 个大的数(当然,100个 ...
- 牛客多校第六场 J Heritage of skywalkert 随即互质概率 nth_element(求最大多少项模板)
链接:https://www.nowcoder.com/acm/contest/144/J来源:牛客网 skywalkert, the new legend of Beihang University ...
- hdu多校第六场1005 (hdu6638) Snowy Smilel 线段树/区间最大和
题意: 给定一个矩阵,矩阵上有若干点,每个点有正或负的权值,找一个方框框住一些点使得方框中点权值最大. 题解: 离散化横纵坐标,容易将这个问题转化为在矩阵上求最大和子矩阵的问题. 普通的n*n的矩阵的 ...
- 2019 牛客多校第六场 J Upgrading Technology
题目链接:https://ac.nowcoder.com/acm/contest/886/J 题目大意 略. 分析 见代码. 代码如下 #include <bits/stdc++.h> u ...
随机推荐
- Python之三层菜单
三层菜单,根据用户所选数字,进入子菜单.一级一级呈现. menu = { 'Beijing': { "ChaoYang": { "CBD": ['CICC', ...
- poj 2417
Accepted 8508K 391MS C++ 2004B 相比下边,,优化太多太多了... /** baby-step-giant-step 因为数据量太大,,自己写hash **/ #inclu ...
- Linux下nc命来实现文件传输
发送端:cat test.txt | nc -l -p 6666或者nc -l -p 6666 < test.txt 有些版本不要在 -p[监听6666端口,等待连接](设发送端IP为10.20 ...
- wordpress 首页模板变量对应表
最近开始学习wp,这里做一些笔记. 首页模板,第一行为前台显示的html代码.第二行为 wp-content/themes/模板目录 下 head.php文件中. 其中我将变量名 html用绿色标记 ...
- Windows10笔记本双显卡导致的启动黑屏解决办法之一
参考链接:http://www.zhihu.com/question/33662311 大概就是关掉ulps. ulps,显卡的多核心超低功率状态,节能用的,AMD出的双显卡的一种节能方案.不过,与某 ...
- java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp
http://stackoverflow.com/questions/13269564/java-lang-classcastexception-oracle-sql-timestamp-cannot ...
- JAVA GUI学习 - JProgressBar进度条组件摘录
public class JProgressBarTest extends JFrame{ public JProgressBarTest() { super(); setTitle("表格 ...
- Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置
Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置 2013年8月14日Android记录 很多应用都会有用户设置,用户的一些偏好可以由用户来决定 ...
- nginx服务器屏蔽上游错误码
平时的开发工作中,有时会遇到脚本权限不对导致403,文件被删除导致404,甚至后端业务异常导致5xx等情况,其实我们可以在服务器加上判断,检测当后端服务出现异常的时候前端返回一个指定的静态文件(也可以 ...
- asp.net js调用后台方法
先前网上百度了很多 ,大致都一样 但是不太详细,总是不成功,然后试了很多,把经验发给大家看看 前台js function aa() { //这里可以写你要带的参数用隐藏域放起来 __doPostBac ...