AtCoder Regular Contest 179
B
Between B and B
AtCoder
⌀ 1432
原题
← AC →
翻译中…

Problem Statement

翻译中…

You are given a sequence $(X_1, X_2, \dots, X_M)$ of length $M$ consisting of integers between $1$ and $M$, inclusive.

翻译中…

Find the number, modulo $998244353$, of sequences $A = (A_1, A_2, \dots, A_N)$ of length $N$ consisting of integers between $1$ and $M$, inclusive, that satisfy the following condition:

翻译中…
  • For each $B = 1, 2, \dots, M$, the value $X_B$ exists between any two different occurrences of $B$ in $A$ (including both ends).
翻译中…

More formally, for each $B = 1, 2, \dots, M$, the following condition must hold:

翻译中…
  • For every pair of integers $(l, r)$ such that $1 \leq l < r \leq N$ and $A_l = A_r = B$, there exists an integer $m$ ($l \leq m \leq r$) such that $A_m = X_B$.
翻译中…

Constraints

翻译中…
  • $1 \leq M \leq 10$
  • $1 \leq N \leq 10^4$
  • $1 \leq X_i \leq M$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

M N
X_1 X_2 \cdots X_M

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 4
2 1 2
Output #1
14
Here are examples of sequences $A$ that satisfy the condition: - $(1, 3, 2, 3)$ - $(2, 1, 2, 1)$ - $(3, 2, 1, 3)$ Here are non-examples: - $(1, 3, 1, 3)$ - There is no $X_3 = 2$ between the $3$s. - $(2, 2, 1, 3)$ - There is no $X_2 = 1$ between the $2$s.
Input #2
4 8
1 2 3 4
Output #2
65536
All sequences of length $8$ consisting of integers between $1$ and $4$ satisfy the condition. Note that when $X_B = B$, there is always a $B$ between two different occurrences of $B$.
Input #3
4 9
2 3 4 1
Output #3
628
题目信息
题号
arc179_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。