AtCoder Grand Contest 064
翻译中…
Problem Statement
翻译中…
You are given a positive integer $N$. Print the number, modulo $998244353$, of sequences $A$ of length $3N$ that contain each integer from $1$ through $N$ three times and satisfy the following condition.
翻译中…
$A$has no contiguous subsequence of length$N$that is a permutation of the sequence$(1, 2, \ldots, N)$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$- All input values are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3
Output #1
132
For instance, $A = (1, 3, 3, 2, 2, 2, 1, 1, 3)$ satisfies the condition in the problem statement. On the other hand, $A = (1, 3, 3, 2, 2, 3, 1, 1, 2)$ does not, because the $5$-th, $6$-th, $7$-th elements of $A$ form a contiguous subsequence that is a permutation of the sequence $(1, 2, 3)$.
Input #2
123456
Output #2
31984851
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。