luogu#P8146. [JRKSJ R4] risrqnis
[JRKSJ R4] risrqnis
Problem Description
You are given a sequence of length . There are operations. Initially, there are empty sets . There are two types of operations, as follows:
1 l r k: Add into set , i.e., .2 l r k: Query, among all for , how many are in set , i.e., query .
Input Format
All inputs are non-negative integers.
The first line contains numbers .
The second line contains numbers, where the -th number denotes .
The next lines each contain 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
| Score | |||
|---|---|---|---|
For of the testdata, , , .
In operation 1, . In operation 2, . In all operations, .
No reaches the maximum values of all constraints. Each 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."

Translated by ChatGPT 5