2 shunfurh shunfurh 于 2017.09.06 19:58 提问

Fool's Game

A card game, often called “Fool's Game”, is quite popular in Russia. We will describe one round of a game for two players.

A standard deck of 36 cards is used. Sometimes the game is carried out using several decks. One suit is declared to be trump. Before the round each player has several cards, one of the player is starting, the other one is covering. For simplicity we will assume, that both players have the same number of cards before the round.

The starting player starts by laying one or several cards of the same rank down on the table. The covering player must in turn cover all the cards with some of her cards. A card can cover another if one of the following is true: it has the same suit and higher rank (ranks are ordered as usually: 6, 7, 8, 9, 10, jack, queen, king, ace), or it is a trump and the card to cover is not a trump (trump can only be covered with a higher trump). After the cards on the table are all covered, the starting player can toss some more cards to be covered. The rank of each card tossed must be among the ranks of the cards already on the table at the moment. Now the newly added cards must be covered by the covering player, after that the starting player can toss more cards, and so on.

The round ends when either the covering player cannot cover the cards on the table, or when the starting player does not want to toss more cards. In the first case the covering player loses the round and takes all the cards from the table, adding them to his cards. In the second case he wins the round and the cards on the table are removed from the game.

Given the cards of both players, and the initial cards layed down by the starting player, find out whether the covering player can always win the round, or the starting player can always force him to lose.

Input

There are mutiple cases in the input file.

The first line of each case contains n --- the number of cards that each of the players has in the beginning of the round (1 <= n <= 36 ), and the trump suit (suit is specified using one letter: ‘S’ for spades, ‘C’ for clubs, ‘D’ for diamonds, ‘H’ for hearts).

The second line contains n card descriptions --- the cards of the starting player. Each card is specified by its rank (‘6’...‘9’, ‘T’ for 10, ‘J’ for jack, ‘Q’ for queen, ‘K’ for king, ‘A’ for ace) and its suit. The cards that are initially layed on the table are marked with asterisk ‘*’ after the description. They always have the same rank. The third line contains n card descriptions --- the cards of the covering player.

You may assume that the game is carried on using several decks, so cards may be duplicated.

There is an empty line after each case.

Output

Output “COVER” if the covering player can always win the round, or “TAKE” if the starting player can always force him to lose.

There should be am empty line after each case.
Sample Input

4 H
6S* 7C 8D KH
7S KH KD AH

4 S
6S* 7C 8D KH
7S KD KD KS

Sample Output

COVER

TAKE

3个回答

caozhy
caozhy   Ds   Rxr 2017.09.22 08:17
已采纳
Gubadong
Gubadong   2017.09.07 02:10

通常被称为“傻瓜游戏”的纸牌游戏在俄罗斯很受欢迎。我们将为两名球员描述一场比赛。使用36张牌的标准牌。有时游戏使用几层甲板进行。一套西装被宣布为特朗普。在回合之前,每个球员都有几张牌,其中一个是首发,另一个是掩护。为了简单起见,我们假设两个玩家在回合前都有相同数量的牌。开始玩家先在桌子上放一张或几张相同的牌。掩护队员必须用她的一些牌掩护所有的牌。卡片可以覆盖另一个如果一个以下是正确的:它有相同的西装和更高的排名(排名通常是命令:6、7、8、9、10日,杰克,王后,国王,ace),或这是一个特朗普和卡封面不是特朗普(trump只能覆盖着更高的特朗普)。在桌子上的牌都被盖上后,开始的玩家可以扔更多的卡片被覆盖。每一张牌的排名都必须列在已经放在桌子上的牌的行列中。现在新添加的牌必须被覆盖的玩家覆盖,之后开始玩家可以扔更多的牌,等等。回合结束时,当被覆球员无法将牌盖在桌子上时,或当开始玩家不想多掷牌时。在第一种情况下,掩护球员输掉了比赛,并将所有的牌从桌子上拿出来,并把他们加到他的牌上。在第二种情况下,他赢得了比赛,桌子上的牌也被移除。考虑到两名球员的牌,以及首发球员的牌,找出球员是否总能赢得比赛,或者首发球员总能迫使他输掉比赛。输入文件中有多个实例。每个案例的第一行包含n - - -卡的数量,每个球员都有一轮的开始(1 < = n < = 36),特朗普西服(套装指定使用一个字母:“年代”黑桃、“C”俱乐部,“D”钻石,“H”的心)。第二行包含n张卡片描述——开始玩家的卡片。每张卡片按等级(“6”)指定。“9”、“T”10、“J”、“Q”、“K”、“K”、“A”和“A”。最初在表格上显示的纸牌在描述后用星号“*”标记。他们的军衔总是一样的。第三行包含n张卡片描述——覆盖播放器的卡片。你可以假设游戏是在几个平台上进行的,所以卡片可能会被复制。每个箱子后面都有一条空的线。输出输出“掩护”如果掩护队员总是能赢球,或者“取”如果首发球员总是能迫使他输。每个箱子后面都应该是空的。

Gubadong
Gubadong   2017.09.07 02:10

通常被称为“傻瓜游戏”的纸牌游戏在俄罗斯很受欢迎。我们将为两名球员描述一场比赛。使用36张牌的标准牌。有时游戏使用几层甲板进行。一套西装被宣布为特朗普。在回合之前,每个球员都有几张牌,其中一个是首发,另一个是掩护。为了简单起见,我们假设两个玩家在回合前都有相同数量的牌。开始玩家先在桌子上放一张或几张相同的牌。掩护队员必须用她的一些牌掩护所有的牌。卡片可以覆盖另一个如果一个以下是正确的:它有相同的西装和更高的排名(排名通常是命令:6、7、8、9、10日,杰克,王后,国王,ace),或这是一个特朗普和卡封面不是特朗普(trump只能覆盖着更高的特朗普)。在桌子上的牌都被盖上后,开始的玩家可以扔更多的卡片被覆盖。每一张牌的排名都必须列在已经放在桌子上的牌的行列中。现在新添加的牌必须被覆盖的玩家覆盖,之后开始玩家可以扔更多的牌,等等。回合结束时,当被覆球员无法将牌盖在桌子上时,或当开始玩家不想多掷牌时。在第一种情况下,掩护球员输掉了比赛,并将所有的牌从桌子上拿出来,并把他们加到他的牌上。在第二种情况下,他赢得了比赛,桌子上的牌也被移除。考虑到两名球员的牌,以及首发球员的牌,找出球员是否总能赢得比赛,或者首发球员总能迫使他输掉比赛。输入文件中有多个实例。每个案例的第一行包含n - - -卡的数量,每个球员都有一轮的开始(1 < = n < = 36),特朗普西服(套装指定使用一个字母:“年代”黑桃、“C”俱乐部,“D”钻石,“H”的心)。第二行包含n张卡片描述——开始玩家的卡片。每张卡片按等级(“6”)指定。“9”、“T”10、“J”、“Q”、“K”、“K”、“A”和“A”。最初在表格上显示的纸牌在描述后用星号“*”标记。他们的军衔总是一样的。第三行包含n张卡片描述——覆盖播放器的卡片。你可以假设游戏是在几个平台上进行的,所以卡片可能会被复制。每个箱子后面都有一条空的线。输出输出“掩护”如果掩护队员总是能赢球,或者“取”如果首发球员总是能迫使他输。每个箱子后面都应该是空的。

Csdn user default icon
上传中...
上传图片
插入图片