这题的题意确实有点难懂.
For each test case output on a single line the balls' weights from label 1 to label N. If several solutions exist:
要注意要求输出的是球1~N的重量.
you should output the one with the smallest weight for label 1, then with the smallest weight for label 2, then with the smallest weight for label 3 and so on:
而且要求当有多解时,球1的质量最轻,then球2的质量最轻,...
也即是说,球号较小的球质量应取到最小.
读懂题意,再用逆序的拓扑排序,问题就不难了.