atcoder#ABC265G. [ABC265G] 012 Inversion
[ABC265G] 012 Inversion
Score : points
Problem Statement
You are given a sequence of length . Each element is , , or . Process queries in order. Each query is of one of the following kinds:
1 L R
: print the inversion number of the sequence .2 L R S T U
: for each such that , if is , replace it with ; if is , replace it with ; if is , replace it with .
What is the inversion number?
The inversion number of a sequence B = (B_1, \ldots, B_M) is the number of pairs of integers (i, j) (1 \leq i < j \leq M) such that B_i > B_j.Constraints
- In each query, .
- In each query of the second kind, .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
denotes the -th query, which is in one of the following formats:
Output
Print the responses to the queries of the first kind in the given order, separated by newlines.
5 3
2 0 2 1 0
1 2 5
2 2 4 2 1 0
1 2 5
3
4
Initially, .
- In the -st query, print the inversion number of .
- The -nd query makes .
- In the -rd query, print the inversion number of .
3 3
0 1 2
1 1 1
2 1 3 0 0 0
1 1 3
0
0