编程介的小学生 2017-10-29 15:12 采纳率: 20.5%
浏览 878
已采纳

The Killers of Two Kingdoms

Problem Description
Due to the popular strategy card game “The Killers of Three Kingdom”, iSea detects the immense market of this game kind, so he decides to SHANZHAI a similar game, The Killers of Two Kingdom.

In this game, there are four kinds of card:

1.Kill: make the enemy loss one unit of life
2.Evade: evade the hurt of “Kill” from enemy, i.e. no loss of life
3.Snitch: steal one card from the enemy if he/she has
4.Defend: stay yourself away from “Snitch” of enemy, i.e. no loss of card

The game is played by only two players; all own three units of life in the beginning. At first, there are N cards in the original pile. Before the rounds begin, the first player takes four cards, then then second player take four cards, and both them will always keep the cards exactly in the order they get them, including the snitched card. There is no limit of card’s number for the players.

While playing the game, two players make an operation in turn, from the first player. As they are stupid AI written by iSea, both of them will take the same strategy.
The one who is in his round will act in this order:

1.Get min {2, the number of left cards} cards first
2.Check if he/she still has “Snitch” Card, use it until none left or can’t use, and try to snitch the first card of the enemy
3.Check if he/she has “Kill” Card, use the first “Kill” card if exists, he/she can use at most one “Kill” in each round

The other one will response in this way:

1.If the enemy play “Snitch” and he/she has “Defend”, use the first one
2.If the enemy play “Kill” and he/she has “Evade”, use the first one

The game ends when one of the played is dead, means own zero unit of life, or when no more cards in the original pile and both of the players can’t play card any more. Once a card had been played, it won’t be used again.
After inventing the rule, iSea find the game is extraordinary boring to play, so he don’t want to play it even only once, try to simulate the game and show him who is the winner or just a tie.

Input
The first line contains a single integer T, indicating the number of test cases.
Each test case begins with an integer N, indicating the number of cards.
Then N Cards’ description following, each of them will be one of the four kinds of cards according to the rules, short for “K”, “E”, “S” and “D”.

Technical Specification

  1. 1 <= T <= 50
  2. 8 <= N <= 100

Output
For each test case, output the case number first, then print “The winner is the first.” or “The winner is the second” or “Just a tie.” (without quotes).

Sample Input
2
8
K K K E K K S S
10
K K S S K K D D E E

Sample Output
Case 1: The winner is the second.
Case 2: Just a tie.

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-19 08:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题