Functional Graph

AtCoder
IDawtf2025_e
Time8000ms
Memory256MB
Difficulty
You are given integers $N$, $C$, and $K$. Find the number, modulo $998244353$, of length-$N$ integer sequences $x=(x_1,x_2,\ldots,x_N)$ satisfying the following conditions. * $1 \leq x_i \leq N$ ($1 \leq i \leq N$). * Consider an undirected graph with $N$ vertices numbered from $1$ to $N$. This graph has $N$ edges, and the $i$\-th edge connects vertices $i$ and $x_i$. Then, the number of connected components of the graph is exactly $C$. * The number of $i$ satisfying $i<x_i$ is exactly $K$. ## Constraints * $1 \leq N \leq 250000$ * $1 \leq C \leq N$ * $0 \leq K \leq N-1$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $C$ $K$ [samples]
Samples
Input #1
3 1 2
Output #1
6

The following six sequences $x$ satisfy the conditions:

*   $x=(2,3,1)$
*   $x=(2,3,2)$
*   $x=(2,3,3)$
*   $x=(3,3,1)$
*   $x=(3,3,2)$
*   $x=(3,3,3)$
Input #2
3 2 2
Output #2
0
Input #3
6 3 0
Output #3
225
Input #4
20 4 7
Output #4
476087626
Input #5
250000 2025 125000
Output #5
410390562
API Response (JSON)
{
  "problem": {
    "name": "Functional Graph",
    "description": {
      "content": "You are given integers $N$, $C$, and $K$. Find the number, modulo $998244353$, of length-$N$ integer sequences $x=(x_1,x_2,\\ldots,x_N)$ satisfying the following conditions. *   $1 \\leq x_i \\leq N$ ($",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 8000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "awtf2025_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given integers $N$, $C$, and $K$. Find the number, modulo $998244353$, of length-$N$ integer sequences $x=(x_1,x_2,\\ldots,x_N)$ satisfying the following conditions.\n\n*   $1 \\leq x_i \\leq N$ ($...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments