There's a special island in Panda Land called Casino Island where all gambling activities are legalized. Here, a well known betting game called Tipu-Tipu is held every month.
Each gambler could place only one bet. Each bet should consists of m
For example:
The prizes for m
The master is: 1 2 3 4 5 6
1-st bet : 1 | m = 1 | prize = 10 |
2-nd bet : 1 2 | m = 2 | prize = 20 |
3-rd bet : 1 2 3 4 | m = 4
| prize = 40 |
4-th bet : 1 2 4 3 | m = 4 | prize = 0 |
5-th bet : 3 1 | m = 2
| prize = 0 |
Total prize = 10 + 20 + 40 + 0 + 0 = 70. |
Of course the owner of the game wants to minimize the total of prize. So he asked you to write a program to find a master sequence which gives the minimum possible total of prize. If there are several of them, find the one which comes first lexicographically.
The first line of input contains an integer T
$(3 \le L \le 30)$
-->
(3
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">L
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">30)
$(1 \le N \le 100000)$
-->
(1
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">N
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">100000)
$m = 1, 2, \ldots, L$
-->
m = 1, 2,..., L
$(1 \le m \le L)$
-->
(1
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">m
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/630.png"
ALT="$ \le$">L)
For each case, print in a single line the master sequence which gives the minimum possible total prize. If there's more than one such sequence, output the one that comes first lexicographically. Each number in the sequence should be separated by a single space.
2
4 3
1 2 3 4
2 1 2
4 2 1 3 4
4 2 1 4 3
4 13
1 2 3 4
2 2 1
4 1 2 3 4
4 1 2 4 3
2 1 3
2 1 4
2 2 3
2 2 4
2 3 1
2 3 2
2 3 4
2 4 1
2 4 2
2 4 3
1 3 2 4
1 3 2 4
Migrated from old NTUJ.
ACM ICPC regional Jakarta site 2008
No. | Testdata Range | Score |
---|