#abc265g. [abc265_g]012 Inversion
[abc265_g]012 Inversion
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 is the number of pairs of integers such that .
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.
Sample Input 1
5 3
2 0 2 1 0
1 2 5
2 2 4 2 1 0
1 2 5
Sample Output 1
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 .
Sample Input 2
3 3
0 1 2
1 1 1
2 1 3 0 0 0
1 1 3
Sample Output 2
0
0