#4622. 012 Inversion
012 Inversion
012 Inversion
题目描述
You are given a sequence of length . Each element is , , or .
Process queries in order. Each query is of one of the following kinds:
: print the inversion number of the sequence . : 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$.输入格式
Input is given from Standard Input in the following format:
denotes the -th query, which is in one of the following formats:
输出格式
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
3 3
0 1 2
1 1 1
2 1 3 0 0 0
1 1 3
0
0
提示
In each query, . In each query of the second kind, . All values in input are integers.Initially, 。
In the -st query, print the inversion number of 。
The -nd query makes 。
In the -rd query, print the inversion number of .
标签: AtCoder|abc265G
来源
AtCoder|abc265G