Zoom
Time limit3sMemory limit1024 MB
Maintain an array under range additions, block copies that repeat a pair of cells, and full replays of past queries, then print range sums modulo 998244353.
- Level
Hard8 of 10
- Topics
- Segment tree, Simulation
- Solved
- No attempts yet
Problem
Sequence of even length is given. Initially, every element of is . Process the following queries.
1 l r b: Add to each of .2 l: For every integer with , replace with . All replacements happen simultaneously.3: Re-run all type 1 and type 2 queries processed so far, in the same order. Queries that were executed by earlier type 3 queries are included.4 l r: Print modulo .
Input
The first line contains the length of the sequence and the number of queries , separated by a space.
Each of the next lines contains one query.
Output
For each type 4 query, print the answer on its own line.
Constraints
- , and is even.
- .
- For every type 1 query, and .
- For every type 2 query, .
- For every type 4 query, .
- At least one type 4 query appears in the input.
- All given numbers are integers.