Missing Subsequence

AtCoder
IDarc186_e
Time2000ms
Memory256MB
Difficulty
You are given a sequence of integers $(X_1,\dots,X_M)$ of length $M$ consisting of $1,\dots,K$. Find the number of sequences $(A_1,\dots,A_N)$ of length $N$ consisting of $1,\dots,K$ that satisfy the following condition, modulo $998244353$: * Among all sequences of length $M$ consisting of $1,\dots,K$, the only sequence that cannot be obtained as a (not necessarily contiguous) subsequence of $(A_1,\dots,A_N)$ is $(X_1,\dots,X_M)$. ## Constraints * $2\le M,K \le N \le 400$ * $1\le X_i \le K$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $K$ $X_1$ $X_2$ $\dots$ $X_M$ [samples]
Samples
Input #1
5 2 3
1 1
Output #1
4

The following four sequences satisfy the condition:

*   $(2, 3, 1, 2, 3)$
*   $(2, 3, 1, 3, 2)$
*   $(3, 2, 1, 2, 3)$
*   $(3, 2, 1, 3, 2)$
Input #2
400 3 9
1 8 6
Output #2
417833302
Input #3
29 3 10
3 3 3
Output #3
495293602
Input #4
29 3 10
3 3 4
Output #4
0
API Response (JSON)
{
  "problem": {
    "name": "Missing Subsequence",
    "description": {
      "content": "You are given a sequence of integers $(X_1,\\dots,X_M)$ of length $M$ consisting of $1,\\dots,K$. Find the number of sequences $(A_1,\\dots,A_N)$ of length $N$ consisting of $1,\\dots,K$ that satisfy the ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc186_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of integers $(X_1,\\dots,X_M)$ of length $M$ consisting of $1,\\dots,K$.\nFind the number of sequences $(A_1,\\dots,A_N)$ of length $N$ consisting of $1,\\dots,K$ that satisfy the ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments