公式
D - LIS ∩ LDS 解説 by evima
Case \(K\geq 2\)
By reversing the last \(K\) elements of \(P=(1,\ldots,N)\), only the last \(K\) elements become good elements. For example, when \(N=7,K=3\), we should output \((1,2,3,4,7,6,5)\).
Case \(K=1\)
For \(N=1\), we can use \(P=(1)\).
For \(N=2,3,4\), exhaustive search of \(P\) proves that no solution exists.
For \(N\geq 5\), we can verify that \(P=(4,1,3,5,2,6,7,8,\ldots,N)\) satisfies the conditions.
Case \(K=0\)
For \(N<8\), exhaustive search of \(P\) proves that no solution exists.
For \(N\geq 8\), we can verify that \(P=(6,5,1,2,7,8,4,3,\ldots,N)\) satisfies the conditions.
投稿日時:
最終更新: