#P13943. [EC Final 2019] Game
[EC Final 2019] Game
题目描述
Alice and Bob are playing . Each of them has a of the following pieces:
- one Field Marshal, order 9
- one General, order 8
- two Major Generals, order 7
- two Brigadier Generals, order 6
- two Colonels, order 5
- two Majors, order 4
- three Captains, order 3
- three Lieutenants, order 2
- three Engineers, order 1
- two Bombs
- three Landmines
To determine the winner, we repeat the following process until someone wins the game or the game ends in a draw:
- If both permutations are empty, the game ends in a draw.
- If Alice's permutation is empty, Bob wins the game.
- If Bob's permutation is empty, Alice wins the game.
- Let the first piece in Alice's permutation be and the first piece in Bob's permutation be . The following is the outcome of the battle between and : -If and are the same types of pieces, or if one of and is Bomb, they are both removed.
- Otherwise, if one of and is Landmine and the other is Engineer, the Landmine is removed and the Engineer stays alive.
- Otherwise, if one of and is Landmine and the other's order is greater than 1, the Landmine stays alive and the other one is removed.
- Otherwise, we compare the order of and and the piece with smaller order is removed.
Bob knows Alice's permutation in advance and can decide his permutation based on that information. After Bob deciding his permutation, Alice can swap two pieces in Bob's permutation. Can Bob construct a permutation that wins against Alice's permutation no matter which pair of pieces she swaps?
输入格式
The first line contains one integer denoting the number of test cases ().
Each of the next lines contains integers denoting Alice's permutation:
- represents Field Marshal
- represents General
- represents Major Generals
- represents Brigadier Generals
- represents Colonels
- represents Majors
- represents Captains
- represents Lieutenants
- represents Engineers
- represents Landmines
- represents Bombs
It is guaranteed that all permutations are chosen uniformly at random and contains exactly the pieces described in the statement.
输出格式
Output one line for each test case.
If Bob cannot construct the required permutation, print .
Otherwise, print integers representing Bob's permutation in the same format as in the input. If there are multiple solutions, print any. Bob's permutation must contain exactly the pieces described in the statement.
4
40 39 38 38 37 37 36 36 35 35 34 34 34 33 33 33 32 32 32 31 31 31 30 30
34 31 36 33 31 39 37 38 35 32 32 35 36 31 34 32 38 40 30 33 30 34 33 37
37 30 40 38 36 38 32 34 36 35 37 32 34 33 31 30 33 31 35 34 33 39 31 32
30 33 32 39 37 38 35 40 34 30 31 37 31 33 31 33 34 32 36 36 35 34 32 38
34 39 35 38 33 34 36 31 37 31 32 37 33 33 35 32 36 38 31 32 30 40 30 34
35 30 32 33 33 38 32 31 35 33 31 37 36 31 39 30 34 32 40 36 34 34 37 38
36 39 34 38 34 32 33 33 30 31 37 33 40 32 34 36 30 32 38 35 31 31 35 37
36 35 34 39 40 33 31 37 31 30 32 38 30 33 33 34 32 34 35 37 36 32 38 31