300555: CF106A. Card Game

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Card Game

题意翻译

一种纸牌游戏。 有许多张卡牌,每张卡牌有一个套装(“S”,“H”,“D”和“C”)和一个等级(按升序排列“6”,“7”,“8”,“9”,“T”, “J”,“Q”,“K”和“A”) **规则:** 以下情况卡牌A才能赢卡牌B: 1、A有王牌套装,B没有 2、A和B的套装相同,但A的等级比B高 否则B赢 **输入格式** 第一行 一个字母(代表王牌套装) 第二行 卡牌A 卡牌B **输出格式** 卡牌A能赢卡牌B输出"YES",否则输出"NO".

题目描述

There is a card game called "Durak", which means "Fool" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly — you can find them later yourselves if you want. To play durak you need a pack of $ 36 $ cards. Each card has a suit ("S", "H", "D" and "C") and a rank (in the increasing order "6", "7", "8", "9", "T", "J", "Q", "K" and "A"). At the beginning of the game one suit is arbitrarily chosen as trump. The players move like that: one player puts one or several of his cards on the table and the other one should beat each of them with his cards. A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. Besides, a trump card can beat any non-trump card whatever the cards’ ranks are. In all other cases you can not beat the second card with the first one. You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.

输入输出格式

输入格式


The first line contains the tramp suit. It is "S", "H", "D" or "C". The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank ("6", "7", "8", "9", "T", "J", "Q", "K" and "A"), and the second one stands for the suit ("S", "H", "D" and "C").

输出格式


Print "YES" (without the quotes) if the first cards beats the second one. Otherwise, print "NO" (also without the quotes).

输入输出样例

输入样例 #1

H
QH 9S

输出样例 #1

YES

输入样例 #2

S
8D 6D

输出样例 #2

YES

输入样例 #3

C
7H AS

输出样例 #3

NO

Input

题意翻译

一种纸牌游戏。 有许多张卡牌,每张卡牌有一个套装(“S”,“H”,“D”和“C”)和一个等级(按升序排列“6”,“7”,“8”,“9”,“T”, “J”,“Q”,“K”和“A”) **规则:** 以下情况卡牌A才能赢卡牌B: 1、A有王牌套装,B没有 2、A和B的套装相同,但A的等级比B高 否则B赢 **输入格式** 第一行 一个字母(代表王牌套装) 第二行 卡牌A 卡牌B **输出格式** 卡牌A能赢卡牌B输出"YES",否则输出"NO".

加入题单

算法标签: