33OJ
登录 注册

#P13983. 数列分块入门 8

    ID: 15783 远端评测题 2000ms 512MiB 尝试: 42 已通过: 7 显示难度普及+/提高− 上传者: 标签>颜色段均摊(珂朵莉树 ODT)

数列分块入门 8

Background

The constraint ranges of the test data of the Luogu Sequence Blocking Primer series differ from those of the original problems.

Problem Description

Given a sequence of length nn and nn operations, where the operations involve querying how many elements in an interval are equal to a number cc, and then changing all elements in this interval to cc.

Input Format

The first line contains a number nn.

The second line contains nn numbers separated by spaces, where the ii-th number is aia_i.

Then nn queries follow, each on one line with three numbers ll, rr and cc separated by spaces.

It means first querying how many numbers in [l,r][l,r] are equal to cc, and then changing all numbers in [l,r][l,r] to cc.

Output Format

For each query, output one line with a single number, the answer.

4
1 2 2 4
1 3 1
1 4 4
1 2 2
1 4 2
1
1
0
2

Hint

Subtasks

Subtask 1 (4040 points): 1≤n≤1000001 \leq n \leq 100000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1.

Subtask 2 (6060 points): 1≤n≤3000001 \leq n \leq 300000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1.

For all test data, 1≤n≤3000001 \leq n \leq 300000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1 and 1≤l≤r≤n1 \leq l \leq r \leq n.

Translated by QwenWork