Random Walk

AtCoder
IDfps_24_r
Time3000ms
Memory256MB
Difficulty
There is a simple undirected graph with $2^N+1$ vertices and $2^N$ edges, where the vertices are numbered $1, 2, \dots, 2^N+1$. The $i$\-th edge connects vertex $i$ and vertex $i+1$. You place a piece on vertex $1$. Then you repeat the following operation exactly $T$ times: * Let the current vertex be $v$. Choose one adjacent vertex of $v$ uniformly at random, and move the piece to that vertex. After $T$ operations, compute the probability that the piece is on vertex $X$, modulo $998244353$. What does probability modulo $998244353$ mean? It can be proven that the probability is always a rational number. Under the constraints of this problem, if the probability is written as $\tfrac{P}{Q}$ with coprime integers $P$ and $Q$, then there exists a unique integer $R$ such that $R \times Q \equiv P \pmod{998244353}$ and $0 \leq R < 998244353$. You are asked to compute this $R$. ## Constraints * $1 \leq N \leq 20$ * $1 \leq T \leq 10^{18}$ * $1 \leq X \leq 2^N+1$ * All input values are integers ## Input The input is given from standard input in the following format: $N$ $T$ $X$ ## Partial Score This problem has partial scoring: * If you solve all datasets with $N \leq 14$, you will earn $3$ points. [samples]
Samples
Input #1
2 3 2
Output #1
249561089

The possible moves and their probabilities are:

*   Move $1 \to 2 \to 3 \to 2$ with probability $\tfrac{1}{4}$.
*   Move $1 \to 2 \to 1 \to 2$ with probability $\tfrac{1}{2}$.

Thus, the answer is $\tfrac{3}{4}$.
Input #2
10 12345 678
Output #2
530802129
API Response (JSON)
{
  "problem": {
    "name": "Random Walk",
    "description": {
      "content": "There is a simple undirected graph with $2^N+1$ vertices and $2^N$ edges, where the vertices are numbered $1, 2, \\dots, 2^N+1$.   The $i$\\-th edge connects vertex $i$ and vertex $i+1$. You place a pie",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "fps_24_r"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is a simple undirected graph with $2^N+1$ vertices and $2^N$ edges, where the vertices are numbered $1, 2, \\dots, 2^N+1$.  \nThe $i$\\-th edge connects vertex $i$ and vertex $i+1$.\nYou place a pie...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments