#P9201. 「GMOI R2-T4」电子木鱼

    ID: 9472 远端评测题 3000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>洛谷原创O2优化动态树 LCT扫描线基环树洛谷月赛分类讨论

「GMOI R2-T4」电子木鱼

Background

Operate electronic capital, recruit cyber Buddhas, and accumulate virtual merit.

Infinite merit, rejoice and praise.

111

Problem Description

You are given nn, meaning there are nn cyber Buddhas in total, numbered 1n1 \sim n.

The ii-th (1in)(1 \leq i \leq n) cyber Buddha can be represented as an ordered pair Si,di\langle S_i, d_i \rangle, where SiS_i is always a subset of {1,2,3,,m}\{1, 2, 3, \dots, m\} at any moment (it can be empty), and did_i is an integer between 1m1 \sim m.

If at some moment, there exists a cyber Buddha whose SiS_i is the empty set, the Buddha will feel very happy and add merit to you. Specifically, he will strike the did_i-th wooden fish, and at the next moment simultaneously affect all nn cyber Buddhas (including himself). For the jj-th (1jn)(1 \leq j \leq n) cyber Buddha, if diSjd_i \in S_j, then delete did_i from SjS_j; otherwise, add did_i into SjS_j. If multiple cyber Buddhas have SiS_i as the empty set, the one with the smallest index ii will add merit to you.

Now, as an electronic capitalist, you want infinite merit. You want to know the minimum number of additional cyber Buddhas you need to hire so that these Buddhas can continuously add merit for you. Suppose this answer is ss (it can be 00), then the new Buddhas are numbered (n+1)(n+s)(n+1) \sim (n+s).

Because you are a capitalist, sometimes you do not want to hire that many Buddhas. So you have many queries. For a query l,rl, r, let f(l,r)f(l, r) denote the answer if initially there are only Buddhas in [l,r][l, r]. Note that each query is independent, and the Buddhas added in the previous query will not carry over to later queries.

To avoid too much output, you only need to output:

$$\sum\limits_{l=1}^n\sum\limits_{r=l}^n f(l,r)\times2^l$$

The answer should be taken modulo 109+710^9 + 7.

Input Format

The first line contains two integers n,mn, m.

The next nn lines: on line ii, first an integer did_i, followed by a 01\texttt{01} string of length mm representing SiS_i. If the jj-th character is 11, it means jSij \in S_i; otherwise jSij \notin S_i.

Output Format

One line, the final answer modulo.

4 3
1 010
2 001
3 000
3 001
52
5 4
1 1000
4 0100
1 0000
2 0001
2 0000
128

Hint

Constraints

This problem uses bundled testdata.

  • Subtask 0 (10 pts): n10n \leq 10, m5m \leq 5.
  • Subtask 1 (10 pts): n300n \leq 300, m10m \leq 10.
  • Subtask 2 (15 pts): n1024n \leq 1024, m10m \leq 10. It is guaranteed that all SiS_i are distinct.
  • Subtask 3 (15 pts): n104n \leq 10^4.
  • Subtask 4 (10 pts): each SiS_i is generated uniformly at random among the 2m2^m possibilities, and each did_i is generated uniformly at random among the mm possibilities.
  • Subtask 5 (40 pts): no special restrictions.

For all data, it is guaranteed that 1n1051 \leq n \leq 10^5, 1m171 \leq m \leq 17.

Translated by ChatGPT 5