显然 $>2$ 的数后面的一定比它小,因此序列一定是两段递减的序列,分别以 $1$ 和 $2$ 结尾。从大往小加数,设 $f(i,j)$ 为加完 $n,n-1,\ldots,i$ 之后,两个序列分别以 $i$ 和 $j$ 结尾的方案数。首先 $i$ 一定可以直接接在 $i+1$ 的后面,所以 $f(i,*)$ 相比 $f(i+1,*)$ 的变化只有 $f(i,i+1)$,可以直接枚举另一边的数计算。时间复杂度 $O(n\log n)$。
QOJ.ac
QOJ
As we are currently experiencing an overwhelming number of web requests for fetching user submissions, we have temporarily disabled the full submissions list. You must now be logged in to view submissions.
Discussion #312 for Problem #1651. Modulo Permutations
Type: Editorial
Status: Open
Posted by: jiangly
Posted at: 2025-12-14 07:02:36
Last updated: 2025-12-14 07:02:38
题解
Comments
No comments yet.