#P3857. [TJOI2008] 彩灯

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

[TJOI2008] 彩灯

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