#P6691. 选择题

    ID: 5559 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>图论2020并查集O2优化广度优先搜索,BFS深度优先搜索,DFS

选择题

Description

This is a multiple-choice question with nn options, and the statement of each option is unique. The content of option ii has the following form:

  • Option aia_i is true / false.

Xiao L thinks that the answer to this kind of question may not be unique, so he wants to ask: how many valid answers does this question have (it is allowed that all options are true or all options are false). He also wants to know, among all these answers, how many true options the answer with the most true options has, and how many true options the answer with the fewest true options has.

Of course, if this question has no valid answer, you can directly reply to Xiao L with No answer.

Input Format

The first line contains a positive integer nn, representing the number of options.

The next nn lines each contain two integers ai,optia_i, opt_i, describing an option. When opti=1opt_i = 1, it means the content of this option is Option aia_i is true; when opti=0opt_i = 0, it means the content of this option is Option aia_i is false.

Output Format

If no answer satisfies this multiple-choice question, output No answer.

Otherwise, output three lines, each containing a positive integer: the number of valid answers, and the numbers of true options in the valid answer with the most true options and in the valid answer with the fewest true options, respectively. The number of valid answers should be taken modulo 998244353998244353.

4
2 1
4 0
1 1
2 0
2
3
1
10
4 1
7 0
2 0
3 1
7 1
5 0
9 1
10 1
8 0
1 1
No answer

Hint

For Sample 1, there are 22 valid answers in total:

  • Options 1,2,31, 2, 3 are true.
  • Option 44 is true.

Among them, the answer with the most true options has 33 true options, and the answer with the fewest true options has 11 true option.

Constraints

For 10%10\% of the testdata, n10n \leq 10.
For 30%30\% of the testdata, n100n \leq 100.
For 60%60\% of the testdata, n103n \leq 10^3.
For 100%100\% of the testdata, n106n \leq 10^6, 1ain1 \leq a_i \leq n, iaii \neq a_i, opti{0,1}opt_i \in \{0, 1\}.

Translated by ChatGPT 5