Mock CCC wouldn't be a real mock CCC without a data structures problem, would it?
You're given two sequences of
Update(l, r, x)
- set through to all be equal to .Query(l, r)
- compute the number of indices where and .
DMOJ has been having some issues with test data taking up too much space, so you're going to generate the operations and solve the problem for us!
Constraints
In tests worth 1 mark,
In tests worth an additional 2 marks,
In tests worth an additional 4 marks,
Input Specification
The first line contains four integers,
The second line contains
The third line contains
Because the number of operations is large, you'll be generating the
int a = A, b = B, C = ~(1<<31), M = (1<<16)-1;
int rnd(int last) {
a = (36969 + (last >> 3)) * (a & M) + (a >> 16);
b = (18000 + (last >> 3)) * (b & M) + (b >> 16);
return (C & ((a << 16) + b)) % 1000000000;
}
The intended solution does not exploit the random number generation used; it would work even if the operations were hand-constructed.
For the rnd
three times, setting rnd(last) % n + 1
, then rnd(last) % n + 1
, then rnd(last) + 1
. If Query(l, r)
. Otherwise, it is Update(l, r, x)
.
last
is always the last return value of Query
. last
starts out being 0
.
Output Specification
Let Update
, and the result of the Query
operation otherwise. Output 998244353
.
Sample Input
5 10 5 6
5 4 5 2 1
1 2 2 4 5
Sample Output
87
Comments
Took me two years to solve this problem