Codeforces Round #772 (Div. 2)
A. Reverse
You are given a permutation p1,p2,…,pn of length n. You have to choose two integers l,r (1≤l≤r≤n) and reverse the subsegment [l,r] of the permutation. The permutation will become p1,p2,…,pl−1,pr,pr−1,…,pl,pr+1,pr+2,…,pn.
Find the lexicographically smallest permutation that can be obtained by performing exactly one reverse operation on the initial permutation.
Note that for two distinct permutati
共有 0 条评论