A13681 | No Game No Life
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Let's consider the following game of Alice and Bob on a directed acyclic graph. Each vertex may contain an arbitrary number of chips. Alice and Bob make turns alternating. Alice goes first. In one turn player can move exactly one chip along any edge outgoing from the vertex that contains this chip to the end of this edge. The one who cannot make a turn loses. Both players play optimally.
Consider the following process that takes place every second on a given graph with $n$ vertices:
1. An integer $v$ is chosen equiprobably from $[1, n + 1]$ .
2. If $v \leq n$ , we add a chip to the $v$ -th vertex and go back to step 1.
3. If $v = n + 1$ , Alice and Bob play the game with the current arrangement of chips and the winner is determined. After that, the process is terminated.
Find the probability that Alice will win the game. It can be shown that the answer can be represented as $\frac{P}{Q}$ , where $P$ and $Q$ are coprime integers and $Q \not\equiv 0 \pmod{998\,244\,353}$ . Print the value of $P \cdot Q^{-1} \bmod 998\,244\,353$ .
Consider the following process that takes place every second on a given graph with $n$ vertices:
1. An integer $v$ is chosen equiprobably from $[1, n + 1]$ .
2. If $v \leq n$ , we add a chip to the $v$ -th vertex and go back to step 1.
3. If $v = n + 1$ , Alice and Bob play the game with the current arrangement of chips and the winner is determined. After that, the process is terminated.
Find the probability that Alice will win the game. It can be shown that the answer can be represented as $\frac{P}{Q}$ , where $P$ and $Q$ are coprime integers and $Q \not\equiv 0 \pmod{998\,244\,353}$ . Print the value of $P \cdot Q^{-1} \bmod 998\,244\,353$ .
输入格式
The first line contains two integers $n$ and $m$ — the number of vertices and edges of the graph ( $1 \leq n \leq 10^5$ , $0 \leq m \leq 10^5$ ).
The following $m$ lines contain edges description. The $i$ -th of them contains two integers $u_i$ and $v_i$ — the beginning and the end vertices of the $i$ -th edge ( $1 \leq u_i, v_i \leq n$ ). It's guaranteed that the graph is acyclic.
The following $m$ lines contain edges description. The $i$ -th of them contains two integers $u_i$ and $v_i$ — the beginning and the end vertices of the $i$ -th edge ( $1 \leq u_i, v_i \leq n$ ). It's guaranteed that the graph is acyclic.
输出格式
Output a single integer — the probability of Alice victory modulo $998\,244\,353$ .
输入输出样例
输入 #1
1 0
输出 #1
0
输入 #2
2 1 1 2
输出 #2
332748118
输入 #3
5 5 1 4 5 2 4 3 1 5 5 4
输出 #3
931694730
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted