2014 HDU多校弟六场J题 【模拟斗地主】

时间:2023-12-30 15:28:02

这是一道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 ;
}