#SRD0000054. Kỷ vật chia xa (Goodbye Souvenir)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Kỷ vật chia xa (Goodbye Souvenir)
Goodbye Souvenir
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
An array of beads has shape labels . In a queried interval , each shape contributes the distance between its last and first occurrences within that interval. A shape appearing once contributes zero. The interval's memory is the sum of these contributions.
Process:
1 p x: change the shape at position to .2 l r: report the current memory of the inclusive interval .
Input
The first line contains and the next line contains the labels . The next lines are 1 p x or 2 l r, with valid one-indexed positions and for range queries.
Output
Print one integer per type-2 query.
Subtasks
- Subtask 1 (10 points): ; . Every color label lies in .
- Subtask 2 (20 points): ; . Every color label lies in .
- Subtask 3 (25 points): ; . Every color label lies in .
- Subtask 4 (45 points): ; . Every color label lies in .
Examples
Input
7 6
1 2 3 1 3 2 1
2 3 7
2 1 3
1 7 2
1 3 2
2 1 6
2 5 7
Output
5
0
7
1
Explanation
In interval , shape occurs at and contributes ; shape occurs at and contributes ; all others contribute zero, so the answer is . Interval has no repeated shape and gives . After the updates, the final two queries yield and .