#P9201. 「GMOI R2-T4」电子木鱼
「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 , meaning there are cyber Buddhas in total, numbered .
The -th cyber Buddha can be represented as an ordered pair , where is always a subset of at any moment (it can be empty), and is an integer between .
If at some moment, there exists a cyber Buddha whose is the empty set, the Buddha will feel very happy and add merit to you. Specifically, he will strike the -th wooden fish, and at the next moment simultaneously affect all cyber Buddhas (including himself). For the -th cyber Buddha, if , then delete from ; otherwise, add into . If multiple cyber Buddhas have as the empty set, the one with the smallest index 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 (it can be ), then the new Buddhas are numbered .
Because you are a capitalist, sometimes you do not want to hire that many Buddhas. So you have many queries. For a query , let denote the answer if initially there are only Buddhas in . 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 .
Input Format
The first line contains two integers .
The next lines: on line , first an integer , followed by a string of length representing . If the -th character is , it means ; otherwise .
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): , .
- Subtask 1 (10 pts): , .
- Subtask 2 (15 pts): , . It is guaranteed that all are distinct.
- Subtask 3 (15 pts): .
- Subtask 4 (10 pts): each is generated uniformly at random among the possibilities, and each is generated uniformly at random among the possibilities.
- Subtask 5 (40 pts): no special restrictions.
For all data, it is guaranteed that , .
Translated by ChatGPT 5