当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7236:If You Can't Beat Them, Join Them!

题目描述
<tt>Roundgod</tt> and <tt>kimoyami</tt> are playing the <strong>graph game</strong> on a directed graph.
Given a directed graph $G=(V,E)$ and a source vertex $s\in V$, the graph game $(G,s)$ is defined as follows:
<ol>
<li> Initially, there is a token on the source vertex $s$. <tt>Roundgod</tt> and <tt>kimoyami</tt> take turns moving the token through a directed edge, with <tt>Roundgod</tt> going first. The game ends when either player cannot make a valid move, and the player who cannot make a move loses. If the game lasts $10^{100}$ turns, then the game is considered a draw. </li>
</ol>

<tt>Roundgod</tt> is not an expert at this game and is often beaten by <tt>kimoyami</tt>. He remembered the famous quote, "If you can't beat them, join them!'', and then came up with the notion of <strong>join of graph games</strong>.
Given a nonempty collection of $k(k>0)$ graph games $(G_1,s_1),\dots,(G_k,s_k)$. The <strong>join</strong> of the $k$ games is also a game with the following definition:
<ol>
<li> <tt>Roundgod</tt> and <tt>kimoyami</tt> take turns moving the tokens in all $k$ graph games <strong>simultaneously</strong>, with <tt>Roundgod</tt> going first. The game ends when either player cannot make a valid move <strong>in any of the $k$ games</strong>, and the player who cannot make a move loses. If the game lasts $10^{100}$ turns, then the game is considered a draw. </li>
</ol>

Now, given a collection of $k$ graph games, $(G_1,s_1),\dots,(G_k,s_k)$, <tt>Roundgod</tt> then needs to choose a <strong>nonempty subset</strong> from the $k$ games and play with <tt>kimoyami</tt> on the <strong>join</strong> of the chosen games. <tt>Roundgod</tt> wonders, how many ways are there to choose such a nonempty subset so that he may win the game under the optimal strategy of both players? As the answer may be too large, you need to output the answer modulo $998244353$.
输入解释
The first line contains an integer $T(1\leq T\leq 5)$, denoting the number of test cases.

For each test case, the first line of the input contains an integer $k(1\leq k\leq 10^6)$, denoting the number of graph games in the collection.

Then the description of $k$ graph games follows.

For the description of the $i(1\leq i\leq k)$-th graph game, the first line contains three integers $n_i,m_i,s_i(1\leq n_i,m_i\leq 10^6,1\leq s_i\leq n_i)$, denoting the number of vertices and edges of in the graph of the $i$th graph game, and the source vertex of the $i$th graph game, respectively.

Then $m_i$ lines follow, each line contains two integers $u,v(1\leq u,v\leq n_i,u\neq v)$, denoting an edge in the graph of the $i$th graph game. Note that it is possible for the graph to have <strong>multiple edges</strong>, but not <strong>self loops</strong>.

It is guaranteed that <strong>for each test case</strong>, $\sum\limits_{i=1}^{k}n_i\leq 2\times 10^6$ and $\sum\limits_{i=1}^{k}m_i\leq 2\times 10^6$
输出解释
Output an integer in a line, denoting the answer taken modulo $998244353$.
输入样例
2
1
4 3 1
1 2
1 3
3 4
3
2 2 1
1 2
2 1
2 1 1
1 2
2 1 2
1 2
输出样例
1
2

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7236

最后修改于 2022-09-15T06:17:33+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
24000/12000MS(Java/Others) 524288/524288K(Java/Others)