#P3673. 小清新计数题

    ID: 2664 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>洛谷原创O2优化枚举,暴力生成树环套树,基环树洛谷月赛

小清新计数题

Description

Xiao A is playing a game on the computer called Truth or Lie.

At the start of the game, the computer gives nn sentences. Each sentence is of the form “Statement xx is true” or “Statement xx is false,” where xx is an integer from 11 to nn. You only need to choose either "Good" or "Bad." "Good" means that you can determine the truth value of each statement so that the content of every sentence holds. "Bad" means the opposite.

As a newbie, Xiao A keeps clicking "Good" and hopes to pass by luck.

After countless failures, Xiao A discovers that in each level, whether a sentence contains the word “true” or “false” is fixed, but the xx in each sentence is chosen uniformly at random from 11 to nn.

Now Xiao A tells you, for a certain level, which word each sentence contains, represented by a 0101 sequence. The ii-th bit being 00 means the ii-th sentence contains “false,” otherwise it contains “true.” He wants to know the number of assignments of the xx’s that make clicking "Good" correct.

Since the number of valid assignments may be large, you need to output the result modulo 998244353998244353.

(If you do not understand the problem, please refer to the sample explanation.)

Input Format

A single line containing a 0101 sequence, whose length is nn.

Output Format

Output the number of valid assignments modulo 998244353998244353.

01
1
10101
1154
10101101010111110100110100101010110001010010101001
322173207

Hint

Sample Explanation

The first sentence says “Some statement is false,” and the second sentence says “Some statement is true.” All possible cases are as follows:

  1. The first sentence says “Statement 1 is false,” the second says “Statement 1 is true.” The result should be Bad.
  2. The first sentence says “Statement 1 is false,” the second says “Statement 2 is true.” The result should be Bad.
  3. The first sentence says “Statement 2 is false,” the second says “Statement 1 is true.” The result should be Bad.
  4. The first sentence says “Statement 2 is false,” the second says “Statement 2 is true.” The result should be Good, because setting the first statement to false and the second statement to true satisfies both sentences, so it is Good.

Therefore, there is exactly one valid assignment.

Constraints

  • For 10%10\% of the testdata, n7n \leq 7.
  • For 20%20\% of the testdata, n9n \leq 9.
  • For 60%60\% of the testdata, n20n \leq 20.
  • For 100%100\% of the testdata, 1n501 \leq n \leq 50.

Translated by ChatGPT 5