Banned X

AtCoder
IDtenka1_2019_f
Time2000ms
Memory256MB
Difficulty
Find the number, modulo $998244353$, of sequences of length $N$ consisting of $0$, $1$ and $2$ such that none of their contiguous subsequences totals to $X$. ## Constraints * $1 \leq N \leq 3000$ * $1 \leq X \leq 2N$ * $N$ and $X$ are integers. ## Input Input is given from Standard Input in the following format: $N$ $X$ [samples]
Samples
Input #1
3 3
Output #1
14

$14$ sequences satisfy the condition: $(0,0,0),(0,0,1),(0,0,2),(0,1,0),(0,1,1),(0,2,0),(0,2,2),(1,0,0),(1,0,1),(1,1,0),(2,0,0),(2,0,2),(2,2,0)$ and $(2,2,2)$.
Input #2
8 6
Output #2
1179
Input #3
10 1
Output #3
1024
Input #4
9 13
Output #4
18402
Input #5
314 159
Output #5
459765451
API Response (JSON)
{
  "problem": {
    "name": "Banned X",
    "description": {
      "content": "Find the number, modulo $998244353$, of sequences of length $N$ consisting of $0$, $1$ and $2$ such that none of their contiguous subsequences totals to $X$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "tenka1_2019_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Find the number, modulo $998244353$, of sequences of length $N$ consisting of $0$, $1$ and $2$ such that none of their contiguous subsequences totals to $X$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 3000$\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments