#P11754. [COCI 2024/2025 #5] 绘图 / Crtež
[COCI 2024/2025 #5] 绘图 / Crtež
Description
A game is given on a sequence of length , initially filled with zeros. During the game, we color positions in the sequence using a series of operations, and we can stop coloring after any operation.
The -th coloring operation is described by the following procedure:
- We select a position containing .
- We decide whether to:
- Paint the selected position with .
- Paint the selected position with color and continue painting adjacent positions to the left with color . We stop painting when we encounter a position with a value less than (which we do not paint) or when we go out of the sequence bounds.
Two games are considered equivalent if, in their final sequences, we can rename the colors greater than , i.e., if there is a bijective mapping such that:
- Colors after mapping remain greater than .
- Each color receives exactly one new label.
- After mapping, both sequences are identical.
An example of equivalent games is:
because there is a mapping of colors (color to color , color to color , color to color ) such that all the above conditions are satisfied.
There are updates given, where for each update, we swap all s with s and all s with s in the interval in the sequence.
After each update, print the number , the number of different games that can be played with an arbitrary number of operations such that no two games are equivalent. Since is very large, print the result modulo .
Input Format
In the first line, there are natural numbers (), representing the number of fields in the sequence and the number of updates.
In the following lines, there are two natural numbers, and (), indicating the positions that describe the update from the problem statement.
Output Format
In the -th of the following lines, print the remainder of the division of the number by after each update.
1 2
1 1
1 1
1
3
3 2
2 2
1 3
9
3
57 2
13 39
6 42
130653412
804077942
Hint
Clarification of the first example:
After the first update, the sequence is equal to . We cannot perform any operations on it, so the maximum number of games we can play is .
After the second update, the sequence is equal to . From the sequence , using the operations described in the problem statement, we can create the sequences , , and . We observe that no pair of these sequences is equivalent, so the maximum number of games we can play is .
Scoring
| Subtask | Points | Constraints |
|---|---|---|
| No additional constraints. |
京公网安备 11011102002149号