Logo
(追記) (追記ここまで)

26465번 - Sharp 2-SAT 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 1024 MB194428.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円$.

제한

예제 입력 1

4 2
2 2
1 -3

예제 출력 1

0
1
2
2
1

예제 입력 2

2 4
-2 2
2 2
2 1
-1 2

예제 출력 2

0
1
1

예제 입력 3

40 10
13 -12
6 4
-19 -17
-6 4
-10 -10
16 17
32 34
-3 -2
-11 -12
37 -36

예제 출력 3

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

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Practice Contest for ICPC Asia Regional > JAG Practice Contest for ICPC 2022 Asia Yokohama Regional E번

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 1: Welcome Contest E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /