#abc276c. [abc276_c]Previous Permutation

[abc276_c]Previous Permutation

给出 1 到 NN 的一个排列(保证不是字典序最小的排列),求它按照字典序的上一个排列。