BFS-ordered Tree

AtCoder
IDawtf2025_d
Time6000ms
Memory256MB
Difficulty
You are given an integer $N$. We call a rooted tree $T$ satisfying the following conditions a **BFS-ordered tree**. * $T$ is a rooted tree with $N$ vertices numbered from $1$ to $N$. * The root is vertex $1$. * Let vertex $p_i$ be the parent of each vertex $i$ ($2 \leq i \leq N$). Then, $p_2 \leq p_3 \leq \cdots \leq p_N$ holds. For each $d=1,2,\ldots,(N-1)$, find the number, modulo $998244353$, of BFS-ordered trees $T$ satisfying the following condition. * The distance between vertices $(N-1)$ and $N$ in $T$ is exactly $d$. More precisely, when considering $T$ as an undirected tree and the path connecting vertices $(N-1)$ and $N$, the number of edges in that path is exactly $d$. ## Constraints * $2 \leq N \leq 10^6$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
2
Output #1
1
Input #2
3
Output #2
1
1
Input #3
4
Output #3
2
2
1
Input #4
5
Output #4
5
5
3
1
Input #5
20
Output #5
477638700
477638700
178405156
178405139
109639972
108787985
86366256
69212603
43976909
22930595
9698374
3355343
947052
215710
38814
5324
524
33
1
API Response (JSON)
{
  "problem": {
    "name": "BFS-ordered Tree",
    "description": {
      "content": "You are given an integer $N$. We call a rooted tree $T$ satisfying the following conditions a **BFS-ordered tree**. *   $T$ is a rooted tree with $N$ vertices numbered from $1$ to $N$. *   The root i",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 6000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "awtf2025_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer $N$. We call a rooted tree $T$ satisfying the following conditions a **BFS-ordered tree**.\n\n*   $T$ is a rooted tree with $N$ vertices numbered from $1$ to $N$.\n*   The root i...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments