Codeforces Round 874 (Div. 3) D. Flipper Solution
AI Translated from Chinese Problem D. Flipper Problem: Given an n-permutation p[], select an interval [l, r] (l <= r), construct a new permutation: a[r+1:] + a[l:r].reverse() + a[1:l] (using Python slice notation, i.e., left-closed right-open interval). Find the lexicographically largest permutation that can be constructed. Analysis Assume the answer is represented by $ ans_i $. Initial analysis: when $ r = n $, $ ans_1 = r_n $, otherwise $ ans_1 = r_{n+1} $. To ensure lexicographic maximum, we need to select the largest possible $ r $. ...
