#P9586. 「MXOI Round 2」游戏

    ID: 10764 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟数学贪心洛谷原创O2优化洛谷月赛

「MXOI Round 2」游戏

Problem Description

Xiao C and Xiao D are playing a fast-growing game.

This game has a total of 33 types of hand cards: Kill, Dodge, Slash. Their uses are as follows:

  • Kill: use it on the opponent; the opponent must use a Dodge, otherwise the opponent loses the game; or respond to the opponent’s Slash.
  • Dodge: respond to the opponent’s Kill.
  • Slash: use it on the opponent; the opponent must use a Kill, otherwise the opponent loses the game.

After a player uses a card, they must discard the card they used.

Starting from Xiao C, each turn belongs to Xiao C and Xiao D alternately. During a player’s turn, that player may play any number of Kill and Slash, and the opponent must make the corresponding responses. Of course, the player may also choose not to play any card and directly enter the opponent’s turn.

Now, Xiao C has c1c_1 Kill cards, c2c_2 Dodge cards, and c3c_3 Slash cards; Xiao D has d1d_1 Kill cards, d2d_2 Dodge cards, and d3d_3 Slash cards. Both sides know each other’s hands. You need to determine what the result of the game will be when both sides use optimal strategies.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, representing the number of test cases.

Then for each test case, one line contains six integers c1,c2,c3,d1,d2,d3c_1,c_2,c_3,d_1,d_2,d_3.

Output Format

For each test case, output one line:

  • If, under optimal play from both sides, Xiao C can win, output C.
  • If, under optimal play from both sides, Xiao D can win, output D.
  • If, under optimal play from both sides, the game ends in a draw, meaning neither side can win, output E.
3
3 1 4 1 5 9
1 1 4 5 1 4
5 2 1 2 6 3
C
D
E

Hint

Sample Explanation #1

For the first set of data, Xiao C can play a Slash first, and after Xiao D responds with a Kill, play another Slash. At this time, Xiao D has used up all Kill cards and cannot respond, so Xiao D loses the game.

Sample #2

See game/game2.in and game/game2.ans in the additional files.

Constraints

For 100%100\% of the testdata, 1T1051 \le T \le 10^5, 0c1,c2,c3,d1,d2,d31090 \le c_1,c_2,c_3,d_1,d_2,d_3 \le 10^9.

Test Point ID Special Property
131\sim3 Guarantee c3=d3=0c_3=d_3=0.
464\sim6 Guarantee c1=d2c_1=d_2 and c2=d1c_2=d_1.
7107\sim10 None.

Translated by ChatGPT 5