#d2864. 兔纸
兔纸
Rabbits
Problem Source
Original problem: P3939 Counting Colors
Hint: this is just a simple simulation. You may use fancy data structures, but you do not have to (some people really do overthink data structures).
Problem Background
The little fish-breeder raises many rabbits.
Problem Description
As everyone knows, rabbits are magical creatures with many fur colors.
The breeder has rabbits lined up from left to right, and the -th rabbit has fur color .
The rabbits are very active and often swap places with a neighbor.
The colorful rabbits dazzle the breeder, who wants to count the rabbits of a certain color in the interval . His math is poor, so can you help him?
Input Format
The first line contains two positive integers : the number of rabbits and the number of operations.
The second line contains positive integers : the colors of the rabbits from left to right in the initial state.
The following lines each have the format 1 x or 2 l r c, where denotes the operation type.
- Operation is a swap: swap the positions of the -th and the -th rabbit.
- Operation is a query: ask how many rabbits of color are in the current interval .
Output Format
For each operation , output one line containing a natural number: the answer.
Sample Input
7 9
8 7 6 6 7 8 3
1 5
1 4
2 1 7 7
1 6
1 4
2 3 6 8
2 1 3 7
2 1 2 6
2 2 5 7
Sample Output
2
1
1
0
1
Constraints
, , and , .