P9586 "MXOI Round 2" Game
Description
Xiao C and Xiao D are playing a fast-growing game.
This game has a total of $3$ 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 $c_1$ Kill cards, $c_2$ Dodge cards, and $c_3$ Slash cards; Xiao D has $d_1$ Kill cards, $d_2$ Dodge cards, and $d_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 $T$, representing the number of test cases.
Then for each test case, one line contains six integers $c_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`.
Explanation/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\%$ of the testdata, $1 \le T \le 10^5$, $0 \le c_1,c_2,c_3,d_1,d_2,d_3 \le 10^9$.
|Test Point ID|Special Property|
|:---:|---|
|$1\sim3$|Guarantee $c_3=d_3=0$.|
|$4\sim6$|Guarantee $c_1=d_2$ and $c_2=d_1$.|
|$7\sim10$|None.|
Translated by ChatGPT 5