| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 8 초 | 1024 MB | 19 | 4 | 4 | 28.571% |
This problem is about the special case of the Satisfiability Problem (SAT). Let's introduce the definition of SAT first.
A SAT instance is a boolean logic formula consisting of several boolean variables combined by AND, OR, and NOT operators and parentheses. An assignment is a mapping from variable to boolean value. An assignment is satisfying a formula if and only if the formula is evaluated to be true with the given assignment. A literal is either a variable or its negation. A clause is a list of literals concatenated with OR. A formula is in Conjunctive Normal Form (CNF) if it consists of clauses concatenated with AND. In the following, we only consider CNF formulae as SAT inputs because every formula can be converted to the equivalent CNF formula. 2-SAT is a special case of SAT where the length of clauses are limited to 2. For example, $(x ∨ y) ∧ (¬x ∨ z)$ is a 2-SAT instance consisting of 3ドル$ variables and 2ドル$ clauses. $x =$ false, $y =$ true, $z =$ true is one of the satisfying assignments for this formula.
You are given a 2-SAT instance in CNF with $N$ variables and $M$ clauses. The $i$-th variable is denoted by $x_i$ and this $i$ is called index. In all clauses, the difference between the indices of the two variables is less than or equal to 2ドル$.
Let $C_k$ be the number of satisfying assignments where exactly $k$ variables are true. Your task is to write a program that calculates $C_k$ for all $k$s 0ドル$ from to $N$.
Since the answer may be huge, print the answer modulo 998ドル,244円,353円$.
The input consists of a single test case with the following format.
$N$ $M$
$A_1$ $B_1$
$\vdots$
$A_M$ $B_M$
The first line consists of two integers, the number of variables $N$ (1ドル ≤ N ≤ 100,000円$) and the number of clauses $M$ (1ドル ≤ M ≤ 100,000円$).
The following $M$ lines represent the clauses in the 2-SAT instance. Each line corresponds to one of the clauses. These lines contain 2ドル$ integers $A_i$ and $B_i$ representing the literals in the clause. They satisfy 1ドル ≤ |A_i | , |B_i | ≤ N$ and $||A_i | − |B_i || ≤ 2$ and each of them has the following meaning: If it is a positive integer $a,ドル the literal is $x_a$ (without negation). If it is a negative integer $b,ドル the literal is $¬x_{-b}$ (with negation).
Output $N+1$ lines. The $i$-th line contains a single integer $C_{i-1}$ modulo 998ドル,244円,353円$.
4 2 2 2 1 -3
0 1 2 2 1
2 4 -2 2 2 2 2 1 -1 2
0 1 1
40 10 13 -12 6 4 -19 -17 -6 4 -10 -10 16 17 32 34 -3 -2 -11 -12 37 -36
0 0 0 4 130 2052 20958 155678 896220 4160798 16004412 51999948 144776190 349181040 735692490 364558777 233997014 242620671 184707628 808271668 924963778 496489648 654440271 639886064 690035227 954668130 474278220 205649340 77168754 24784920 6715462 1505398 271728 37950 3848 252 8 0 0 0 0