luogu#P3857. [TJOI2008] 彩灯

    ID: 2791 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2008各省省选进制线性基构造天津

[TJOI2008] 彩灯

Background

Peter’s girlfriend’s birthday is coming, and he designed a set of colored lights as a surprise. A set consists of a row of NN independent bulbs, controlled by MM switches. Mathematically, each bulb has exactly two states, on or off, so there are 2N2^N possible patterns. Due to technical reasons, the bulbs controlled by each switch have no particular pattern: when a switch is pressed, it toggles the state of every bulb it controls (on becomes off, off becomes on). Given the set of bulbs each switch controls, can you compute how many distinct lighting patterns can be displayed?

Note: Initially, all bulbs are off.

Output Format

Output the number of distinct patterns obtainable by these switches and bulbs. Since this number can be large, output it modulo the integer 20082008.

2 3
OO
XO
OX

4

Hint

As seen in the sample, the first switch controls all bulbs, while the next two switches control the first and second bulbs respectively. In this case, using only the latter two switches suffices to obtain all 222^2 states.

Constraints:

  • For 30%30\% of the testdata, NN and MM do not exceed 1515.
  • Additionally, for 40%40\% of the testdata, one of NN and MM equals 5050.
  • For 100%100\% of the testdata, NN and MM do not exceed 5050.

Translated by ChatGPT 5