#P2565. [SCOI2009] 骰子的学问
[SCOI2009] 骰子的学问
Description
Xiao Yu'er is a math genius. One night he studied a Penney-ante game related to strings. The rules are as follows:
- There are two players. At the beginning, each chooses a string of the same length.
- A character generator keeps randomly generating letters and appending them to the end of string , which is initially empty.
- If contains the string chosen by a player, the game ends and that player wins.
Suppose players 1 and 2 choose strings and respectively. If player 1 can defeat player 2 with higher probability, we write . At first glance, Xiao Yu'er thought that if and then . However, the opposite is true: there exist strings such that , , and .
Xiao Yu'er was fascinated by this counterintuitive phenomenon. From the literature, he learned that this is called the "non-transitivity paradox", which often appears in many imperfect-information games (such as military chess). But how does it arise? Xiao Yu'er decided to design a game in which it is easy to find non-transitive examples, to better understand "non-transitivity". Of course, the simpler the game, the deeper the idea; thus Xiao Yu'er thought of the simplest dice-rolling game.
The game is as follows. Assume there are dice , each with faces. Each face is labeled with a positive integer from to , and across all dice, the faces have pairwise distinct labels. If the above labeling requirement is satisfied and each face is equally likely to be rolled, such dice are called a set of "good dice". At the start of the game, the two players choose two dice and ; they each roll once and compare the numbers on the rolled faces, and the larger number wins.
Xiao Yu'er asks you to design a set of "good dice" such that for every die , it always beats . Here, "beat" means the probability that the player choosing the former wins exceeds ; are the input integers in .
Input Format
The first line contains two integers . The second line contains integers, namely .
Output Format
Output lines, each containing distinct integers in , separated by spaces.
If there are multiple solutions, output any one of them. If there is no solution, output a single integer .
3 3
2 3 1
1 6 8
3 5 7
2 4 9
3 4
2 1 2
0
3 4
2 3 1
1 3 10 11
2 7 8 9
4 5 6 12
4 4
4 1 2 3
1 11 8 14
12 15 2 5
3 6 16 9
4 10 13 7
Hint
- 30% of the testdata satisfies .
- 100% of the testdata satisfies .
Thanks to @cn: 苏卿念 for providing the SPJ.
Translated by ChatGPT 5
京公网安备 11011102002149号