luogu#P8146. [JRKSJ R4] risrqnis

    ID: 7272 远端评测题 3000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2022颜色段均摊(珂朵莉树 ODT)洛谷原创O2优化分块扫描线根号分治

[JRKSJ R4] risrqnis

Problem Description

You are given a sequence a1na_{1\sim n} of length nn. There are qq operations. Initially, there are mm empty sets S1mS_{1\sim m}. There are two types of operations, as follows:

  • 1 l r k: Add lrl\sim r into set SkS_k, i.e., SkSk{xx[l,r]N}S_k\gets S_k\cup\{x|x\in[l,r]\cap \N\}.
  • 2 l r k: Query, among all aia_i for lirl\le i\le r, how many are in set SkS_k, i.e., query i=lr[aiSk]\displaystyle\sum_{i=l}^r[a_i\in S_k].

Input Format

All inputs are non-negative integers.

The first line contains 33 numbers n,q,mn, q, m.
The second line contains nn numbers, where the ii-th number denotes aia_i.
The next qq lines each contain 44 numbers, describing one operation.

Output Format

All outputs are non-negative integers.

For each operation of type 2, output one line with the answer.

5 10 2
5 4 3 2 1
2 1 5 1
2 1 5 2
1 2 3 1
1 2 3 2
2 1 4 1
2 1 4 2
1 1 4 1
1 1 4 2
2 1 5 1
2 3 5 2
0
0
2
2
4
3

Hint

Constraints

Subtask\text{Subtask} n,qn,q\le mm\le Score
11 10610^6 11 3030
22 5×1035\times 10^3 3×1053\times 10^5 1515
33 10510^5
44 3×1053\times 10^5 10910^9 4040

For 100%100\% of the testdata, 1n,q1061\le n,q\le 10^6, 1m1091\le m\le 10^9, 1ai1091\le a_i\le 10^9.

In operation 1, 1lr1091\le l\le r\le 10^9. In operation 2, 1lrn1\le l\le r\le n. In all operations, 1km1\le k\le m.

No Subtask\text{Subtask} reaches the maximum values of all constraints. Each Subtask\text{Subtask} has its own limits. Please read the constraints table.

The input file of this problem is large. Please use an appropriate input method.


Late at night, Touma Kamijou's phone made the sound of receiving a message. Then, he came to the place written in the email: the iron bridge in District 7.

When Kamijou arrived, the sender had already been waiting there.

"Misaka...?"

"The thing you forgot."

As she spoke, she threw something over. Kamijou caught it with one hand and found it was a Gekota phone charm. This should have been lost when he sank into the Arctic Ocean. The strap used to tie it to the phone had been shattered back then, but now it had been replaced with a strap of another color.

"I finally managed to find it. Don't lose it again."

"Sorry."

Kamijou thanked her and tied it to his phone again.

Seeing that, Mikoto smiled slightly.

It was an expression as if she had finally restored something to the way it should be, and let out a sigh of relief.

"I figure a guy like you won't stay in one place forever... Next, are you going somewhere again?"

"Pretty much."

Kamijou sighed.

"Honestly, even though I look calm, I'm actually totally confused about what exactly is happening. I only know the name of the one behind it. But this disturbance has already spread to Academy City, and I, who am investigating Academy City, got dragged into it. The Academy City I'm investigating got dragged in as well... so I can't just ignore it."

It seemed Mikoto had only come to deliver the charm. Kamijou put his phone into his pocket.

Since there was no topic left, they could only part ways.

"Goodbye." Kamijou said.

He turned his back to Mikoto and was about to leave the iron bridge,

about to leave this Academy City built on scientific common sense, and stride into the outside world. But the boy's hand was grabbed by Mikoto.

Firmly, tightly, she held onto the boy who wanted to drift away.

By Kamijou's motionless ear, Mikoto's voice came.

"But this time, you won't be alone."

114514

Translated by ChatGPT 5