#abc265g. G - 012 Inversion
G - 012 Inversion
Score : points
问题描述
给定一个长度为 的序列 ,其中每个元素为 、 或 。
按顺序处理 个查询。每个查询属于以下两种类型之一:
1 L R
:打印子序列 的逆序数。2 L R S T U
:对于满足 的所有 ,若 为 ,则将其替换为 ;若 为 ,则替换为 ;若 为 ,则替换为 。
什么是逆序数?一个序列 的逆序数是指满足条件 且 的整数对的数量。
以上为通义千问 qwen-max 翻译,仅供参考。
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
update @ 2024/3/10 11:13:18