编程介的小学生 2017-09-06 11:58 采纳率: 20.5%
浏览 908
已采纳

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条回答 默认 最新

  • threenewbee 2017-09-22 00:17
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误