CF1411G.No Game No Life

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn vertices:

  1. An integer vv is chosen equiprobably from [1,n+1][1, n + 1] .
  2. If vnv \leq n , we add a chip to the vv -th vertex and go back to step 1.
  3. If v=n+1v = 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 PQ\frac{P}{Q} , where PP and QQ are coprime integers and Q≢0(mod998244353)Q \not\equiv 0 \pmod{998\,244\,353} . Print the value of PQ1mod998244353P \cdot Q^{-1} \bmod 998\,244\,353 .

输入格式

The first line contains two integers nn and mm — the number of vertices and edges of the graph ( 1n1051 \leq n \leq 10^5 , 0m1050 \leq m \leq 10^5 ).

The following mm lines contain edges description. The ii -th of them contains two integers uiu_i and viv_i — the beginning and the end vertices of the ii -th edge ( 1ui,vin1 \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 998244353998\,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
首页