問題一覧 > 通常問題

No.770 Median Sequence

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 12
作問者 : Pulmn
お気に入りにしたユーザー ProblemId : 2475 / 自分の提出
問題文最終更新日: 2018-12-17 22:57:03
Median Sequence
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Advent Calendar Contest 2018 (順位表) の他の問題:

Problem Statement

Find the number of integer sequences $A$ of length $N$ that satisfy the following condition. Since this value can be very large, output the remainder when divided by $10^9+7$.

Condition: There exists an integer sequence $B$ of length $N$, with each element between $1$ and $N$ inclusive, that satisfies the following equations. Here, $med(x,y,z)$ denotes the median of the $3$ values $\{x,y,z\}$.

$A_1=med(1,B_1,N)$
$A_2=med(med(1,B_1,N-1),B_2,N)$
$A_3=med(med(med(1,B_1,N-2),B_2,N-1),B_3,N)$
 $\vdots$
$A_i=med(med(med(\dots med(\dots med(med(1,B_1,N-i+1),B_2,N-i+2),\dots ,B_j,N-i+j)\dots ),B_{i-1},N-1),B_i,N)$
 $\vdots$
$A_N=med(med(med(\dots med(\dots med(med(1,B_1,1),B_2,2),\dots ,B_j,j)\dots ),B_{N-1},N-1),B_N,N)$

* Please refer to the samples.

Input

$N$

$1\le N\le 3,000$

Output

Output the number of integer sequences $A$ satisfying the condition, modulo $10^9+7$. Print a newline at the end.

Sample

Sample 1
Input
6
Output
1448

For example, $A=(1,2,6,5,4,6)$ satisfies the condition, since taking $B=(1,2,6,3,1,6)$ satisfies the following equations.
$A_1=med(1,B_1,6)$
$A_2=med(med(1,B_1,5),B_2,6)$
$A_3=med(med(med(1,B_1,4),B_2,5),B_3,6)$
$A_4=med(med(med(med(1,B_1,3),B_2,4),B_3,5),B_4,6)$
$A_5=med(med(med(med(med(1,B_1,2),B_2,3),B_3,4),B_4,5),B_5,6)$
$A_6=med(med(med(med(med(med(1,B_1,1),B_2,2),B_3,3),B_4,4),B_5,5),B_6,6)$

Sample 2
Input
1
Output
1

Sample 3
Input
100
Output
328638438

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。