Sequence Master
Given is a sequence $A$ of length $N$. Define $f(i,j)$ to be the number of distinct elements in $A_i,A_{i+1},\ldots,A_j$. You need to process $Q$ queries of the following two types: - $1\ x\ y$ — set $A_x = y$. - $2\ k$ — print $\sum\limits_{i=1}^{k}\sum\limits_{j=i}^{k}f(i,j)$. ### Input - The first line of input contains two integers $N$ and $Q$ — the size of the array and the number of quer
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start