C4

AtCoder
IDagc051_d
Time2000ms
Memory256MB
Difficulty
In the following undirected graph, count the number of walks from $S$ to $S$ that pass through the edges $ST$, $TU$, $UV$, $VS$ (in any direction) exactly $a$, $b$, $c$, $d$ times, respectively, modulo $998,244,353$. ![image](https://img.atcoder.jp/agc051/48a379ab79ee4edf503b84c8b7984d50.png) ## Constraints * $1 \leq a, b, c, d \leq 500,000$ * All values in the input are integers. ## Input Input is given from Standard Input in the following format: $a$ $b$ $c$ $d$ [samples] ## Notes A walk from $S$ to $S$ is a sequence of vertices $v_0 = S, v_1, \ldots, v_k = S$ such that for each $i (0 \leq i < k)$, there is an edge between $v_i$ and $v_{i+1}$. Two walks are considered distinct if they are distinct as sequences.
Samples
Input #1
2 2 2 2
Output #1
10

There are $10$ walks that satisfy the condition. One example of such a walk is $S$ $\rightarrow$ $T$ $\rightarrow$ $U$ $\rightarrow$ $V$ $\rightarrow$ $U$ $\rightarrow$ $T$ $\rightarrow$ $S$ $\rightarrow$ $V$ $\rightarrow$ $S$.
Input #2
1 2 3 4
Output #2
0
Input #3
470000 480000 490000 500000
Output #3
712808431
API Response (JSON)
{
  "problem": {
    "name": "C4",
    "description": {
      "content": "In the following undirected graph, count the number of walks from $S$ to $S$ that pass through the edges $ST$, $TU$, $UV$, $VS$ (in any direction) exactly $a$, $b$, $c$, $d$ times, respectively, modul",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc051_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In the following undirected graph, count the number of walks from $S$ to $S$ that pass through the edges $ST$, $TU$, $UV$, $VS$ (in any direction) exactly $a$, $b$, $c$, $d$ times, respectively, modul...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments