QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#13348. 新年的追逐戰

Statistics

杰瑞正在被湯姆追捕!

為了擺脫追捕,傑瑞需要知道地圖上有多少個老鼠洞可以隱藏!

但兩隻鞋太太的家實在太大了,為了簡單地說明,定義兩個簡單無向圖 $G_{1} =( V_{1} ,E_{1}) ,G_{2} =( V_{2} ,E_{2})$ 的乘積為一個新的圖 $G_{1} \times G_{2} =\left( V^{*} ,E^{*} \right)$。

其中新的點集 $V^{*}$ 為:

$$ V^{*} = \left\{{(a,b)| a \in V_{1}, b \in V_{2}}\right\} $$

其中新的邊集 $E^{*}$ 為:

$$ E^{*} =\left\{\left(( u_{1} ,v_{1}) ,( u_{2} ,v_{2})\right) \mid ( u_{1} ,u_{2}) \in E_{1}, ( v_{1} ,v_{2}) \in E_{2}\right\} $$

對於正整數 $n$,以及給定的圖 $G_{1} ,G_{2} ,\dotsc ,G_{n}$,兩隻鞋太太的家可以表示成

$$ H = (((G_1 \times G_2) \times G_3) \times \cdots) \times G_n $$

為了方便逃亡(戲弄湯姆),對於同一個連通塊,傑瑞事先打通了所有的老鼠洞,你只需要計算一遍。

為了方便逃亡(戲弄湯姆),對於任何一個連通塊,都有老鼠洞。

也就是說,你需要求的是 $H$ 的連通塊數量。但是傑瑞忘記了每個 $G_k$ 的具體細節,所以我們現在假設每個 $G_k$ 中任意兩點間都有 $\frac12$ 的機率連邊,求 $H$ 的連通塊的期望。顯然 $G_k$ 的全體取法共有 ${\large {2^{\binom{m_1}2 + \binom{m_2}2 + \cdots + \binom{m_n}2}}}$ 種。

方便起見,你只需要輸出答案乘以 ${\large {2^{\binom{m_1}2 + \binom{m_2}2 + \cdots + \binom{m_n}2}}}$,對 $998244353$ 取模即可。

輸入格式

第一行輸入一個正整數 $n$。

接下來一行輸入 $n$ 個正整數,第 $k$ 個正整數為 $m_k$,表示第 $k$ 個圖的頂點數量。

輸出格式

輸出一個整數,表示答案 $\bmod 998244353$。

範例

範例輸入 1

1
3

範例輸出 1

13

說明 1

注意對於 $n=1$ 的情況,就是枚舉所有節點個數為 $m_1$ 的帶標號無向圖的連通塊數量之和。

範例輸入 2

2
2 3

範例輸出 2

73

說明 2

$G_1$ 中有 $0$ 條邊的情況下,任何一種 $G_2$ 都會導致 $H$ 中有 $6$ 個連通塊,這樣的方案共有 $8$ 種。

$G_1$ 中有 $1$ 條邊,$G_2$ 中有 $0$ 條邊的情況下,$H$ 中有 $6$ 個連通塊,這樣的方案有 $1$ 種。

$G_1$ 中有 $1$ 條邊,$G_2$ 中有 $1$ 條邊的情況下,$H$ 中有 $4$ 個連通塊,這樣的方案有 $3$ 種。

$G_1$ 中有 $1$ 條邊,$G_2$ 中有 $2$ 條邊的情況下,$H$ 中有 $2$ 個連通塊,這樣的方案有 $3$ 種。

$G_1$ 中有 $1$ 條邊,$G_2$ 中有 $3$ 條邊的情況下,$H$ 中有 $1$ 個連通塊,這樣的方案有 $1$ 種。

$$ 6\times 8 + 6\times 1 + 4\times 3 + 2\times 3 + 1\times 1 = 73 $$

範例輸入 3

2
4 4

範例輸出 3

21565

資料範圍

測試點編號$n$$m_k$
$1$$\le 4$$\le 4$
$2$$ = 1$$\le 10^3$
$3$$ = 1$$\le 10^5$
$4$$ = 2$$\le 10^3$
$5$$ = 2$$\le 10^5$
$6$$\le 10^3$$\le 10^3$
$7$$\le 10^5$$\le 10^3$
$8$$\le 10^5$$\le 10^5$
$9$$\le 10^5$$\le 10^5$
$10$$\le 10^5$$\le 10^5$

對於所有測試資料,滿足 $1\le n, m_k\le 10^5$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.