CF106A.Card Game
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
有一种名为“Durak”(俄语中意为“傻瓜”)的纸牌游戏,在前苏联各国广为流行。本题并未详述该游戏的所有规则——如有兴趣,你可自行查阅。
玩 Durak 需要一副 36 张的牌。每张牌有一个花色("S"、"H"、"D" 和 "C")和一个点数(按升序排列为:"6"、"7"、"8"、"9"、"T"、"J"、"Q"、"K" 和 "A")。游戏开始时,任意选定一种花色作为将牌(trump)。
玩家轮流进行如下操作:一名玩家将一张或多张自己的牌置于桌上,另一名玩家则需用自己手中的牌逐一将这些牌击溃(即“击败”)。
一张牌能击败另一张牌,当且仅当满足以下条件之一:
- 两张牌花色相同,且前一张牌的点数高于后一张牌;
- 前一张牌为将牌,而后一张牌不是将牌(此时无论点数大小,均可击败)。
其余所有情形下,第一张牌均不能击败第二张牌。
现给出将牌花色以及两张互不相同的牌,请判断第一张牌是否能击败第二张牌。
输入格式
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").
第一行包含将牌花色,为 "S"、"H"、"D" 或 "C" 之一。
第二行包含两张不同牌的描述。每张牌由一个包含两个字符的单词表示:第一个字符表示点数("6"、"7"、"8"、"9"、"T"、"J"、"Q"、"K" 和 "A"),第二个字符表示花色("S"、"H"、"D" 和 "C")。
输出格式
Print "YES" (without the quotes) if the first cards beats the second one. Otherwise, print "NO" (also without the quotes).
如果第一张牌击败第二张牌,则输出 "YES"(不带引号)。否则,输出 "NO"(同样不带引号)。
输入输出样例
输入#1
H QH 9S
输出#1
YES
输入#2
S 8D 6D
输出#2
YES
输入#3
C 7H AS
输出#3
NO
输入解题思路,AI测评打分。不知道怎么写?