#P9586. Card Duel Game

    ID: 22733 Type: Default 1000ms 256MiB

Card Duel Game

Card Duel Game

Two players, C and D, are playing a rising card game. In this game there are three types of cards:

  • Kill (\(\mathtt{杀}\)): When a player uses a Kill card on the opponent, the opponent must immediately respond by using either a Dodge card (\(\mathtt{闪}\)) or a Slash card (\(\mathtt{斩}\)). If the opponent is unable to respond, they lose the game.
  • Dodge (\(\mathtt{闪}\)): This card is used solely to respond to a Kill attack.
  • Slash (\(\mathtt{斩}\)): When a player uses a Slash card on the opponent, the opponent must respond by using a Kill card. Failure to do so results in an immediate loss.

Important rules:

  1. After a player uses a card (either as an attack or as a response), that card is discarded.
  2. The game proceeds in turns starting with player C and then alternating between C and D.
  3. On each turn, the active player may launch any number (including zero) of attacks. Attacks can be either Kill or Slash cards.
  4. The defending player must respond appropriately for each attack: for a Kill attack, they can use either a Dodge card or a Slash card; for a Slash attack, they must use a Kill card if available.
  5. Both players know the opponent's hand cards.

Player C has \(c_1\) Kill cards, \(c_2\) Dodge cards, and \(c_3\) Slash cards. Player D has \(d_1\) Kill cards, \(d_2\) Dodge cards, and \(d_3\) Slash cards.

Assume that both players play optimally. The following strategy analysis applies:

  • When attacking with a Kill card, the opponent can defend if they have at least one Dodge or Slash card. Thus, if the number of Kill attacks exceeds \(d_2+d_3\), player C can force a win with Kill attacks.
  • When attacking with a Slash card, the opponent must use a Kill card. Therefore, if the number of Slash attacks exceeds \(d_1\), player C can force a win with Slash attacks.
  • Similarly for player D on his turn: if \(d_1 > c_2+c_3\) or \(d_3 > c_1\), player D can force a win.

Thus, the outcome is determined as follows:

[ \text{If } (c_1 > d_2+d_3) \text{ or } (c_3 > d_1) \text{, then player C wins.} ]

[ \text{Else if } (d_1 > c_2+c_3) \text{ or } (d_3 > c_1) \text{, then player D wins.} ]

Otherwise, if neither player can force a win immediately, the game ends in a draw.

inputFormat

The input consists of a single line containing six space-separated integers:

  • c1 c2 c3 d1 d2 d3

Where:

  • \(c_1\) is the number of Kill cards player C has
  • \(c_2\) is the number of Dodge cards player C has
  • \(c_3\) is the number of Slash cards player C has
  • \(d_1\) is the number of Kill cards player D has
  • \(d_2\) is the number of Dodge cards player D has
  • \(d_3\) is the number of Slash cards player D has

outputFormat

Output a single line containing:

  • C if player C wins,
  • D if player D wins,
  • Draw if neither player can force a win.

sample

1 0 1 0 0 0
C