Case 1
$$$[1,2,3,\dots ,x][x+1,x+2,\dots ,y,1,2,3,\dots,x-1]$$$
$$$[1,2,3,\dots ,x,x+1,x+2,\dots ,y][1,2,3,\dots,x-1]$$$
take either
take the example in the officail tutorial:
$$$[1,2,3,1,2,1]$$$
$$$[1,2,3]+[1,2]+[1]$$$
$$$[1,2]+[3,1,2]+[1]$$$
It inspire me to ban the $$$[1,2,\dots x][x+1\dots]$$$ situation.
Case 2
$$$[k,k+1,\dots,x,1,2,3,\dots,k-1][k,k+1,\dots]$$$
There should be no misunderstanding.
Solution
The $$$O(n^4)$$$ brute force.
I didn't come up with it during the contest,though.
https://mirror.codeforces.com/contest/2124/submission/327909733
I wrote another $$$O(n^3)$$$ dp.
https://mirror.codeforces.com/contest/2124/submission/327819126
But I can't optimize it.
So what is tutorial say is right.
https://mirror.codeforces.com/contest/2124/submission/327928111
https://mirror.codeforces.com/contest/2124/submission/327928858








