[YsOI2023] 连通图计数

Luogu
IDLGP9535
Time1000ms
Memory512MB
DifficultyP7
数学洛谷原创O2优化洛谷月赛
请问有多少个 $n$ 个点 $m$ 条边的**无向简单连通**图,无自环无重边,满足删掉编号为 $i$ 的点后无向图被分成了 $a_i$ 个连通块。特殊地,我们保证 $n-1\le m\le n+1$,且答案不为 $0$。 答案对 $998,244,353$ 取模。 ## Input 第一行两个整数 $n,m$。 第二行 $n$ 个整数,第 $i$ 个整数为 $a_i$。 ## Output 输出一行一个整数,表示答案对 $998,244,353$ 取模得到的结果。 [samples] ## Background Ysuperman 模板测试的多项式题。 【数据删除】 ## Note #### 样例 1 解释 共有三种可能的图,连的四条边分别为: 1. $(1,2),(1,3),(1,4),(2,3)$。 2. $(1,2),(1,3),(1,4),(2,4)$。 3. $(1,2),(1,3),(1,4),(3,4)$。 #### 数据范围 |测试点编号|$n,m$|特殊性质| |:-:|:-:|:-:| |$1\sim 4$|$m=n-1$|无| |$5\sim 6$|$m=n$,$n\le 7$|无| |$7\sim 8$|$m=n$|$a_i=1$| |$9\sim 12$|$m=n$|无| |$13\sim 14$|$m=n+1$,$n\le 7$|无| |$15\sim 16$|$m=n+1$|$a_i=1$| |$17\sim 20$|$m=n+1$|无| 对于所有的数据,满足 $4\le n\le 10^5$,$n-1\le m\le n+1$,$1\le a_i<n$,$n\le \sum_{i=1}^na_i\le 2n-2$,且保证答案非 $0$。
Samples
Input #1
4 4
2 1 1 1
Output #1
3
Input #2
4 5
1 1 1 1
Output #2
6
Input #3
5 6
1 1 2 1 1
Output #3
27
Input #4
6 6
1 2 3 1 1 1
Output #4
30
Input #5
6 5
2 1 1 1 1 4
Output #5
4
Input #6
8 7
1 1 3 1 2 2 2 2
Output #6
360
Input #7
8 8
1 1 1 1 2 2 2 2
Output #7
2520
Input #8
8 9
1 1 1 1 1 1 2 3
Output #8
9240
Input #9
10 11
1 1 1 4 2 2 2 1 1 1
Output #9
105840
Input #10
12 13
1 1 1 1 1 1 1 1 1 1 1 1
Output #10
518269694
API Response (JSON)
{
  "problem": {
    "name": "[YsOI2023] 连通图计数",
    "description": {
      "content": "请问有多少个 $n$ 个点 $m$ 条边的**无向简单连通**图,无自环无重边,满足删掉编号为 $i$ 的点后无向图被分成了 $a_i$ 个连通块。特殊地,我们保证 $n-1\\le m\\le n+1$,且答案不为 $0$。 答案对 $998,244,353$ 取模。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P7"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9535"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "请问有多少个 $n$ 个点 $m$ 条边的**无向简单连通**图,无自环无重边,满足删掉编号为 $i$ 的点后无向图被分成了 $a_i$ 个连通块。特殊地,我们保证 $n-1\\le m\\le n+1$,且答案不为 $0$。\n\n答案对 $998,244,353$ 取模。\n\n## Input\n\n第一行两个整数 $n,m$。\n\n第二行 $n$ 个整数,第 $i$ 个整数为 $a_i$。\n\n## Outp...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments