P4690 [Ynoi Easy Round 2016] Insects in the Mirror

Background

Are there beautiful things in the world inside a mirror? Are there happy things in the world inside a mirror? Me in the mirror world, wearing the same bored expression as I do. — From *Alice in the Mirror Country* ![](https://cdn.luogu.com.cn/upload/pic/21104.png) A battle story of two girls. Literature represents a strong will, and chemistry is the power to resist the physical world. These are the only two weapons they have to fight reality. ![](https://cdn.luogu.com.cn/upload/pic/21105.png) Ah, Leblanc! Today I am going to climb onto the milky-white moon! There is no need to invent a machine. Indeed, I will leap out in one jump! That’s right, my friend! The world of that moon! That is the world created for us! More than one person I love was probably exiled there... and is waiting for me... Socrates! Galileo! The soul of the basic elements of matter is... This is... no, something is wrong... Copernicus said it before! That’s right, my friends. Why on earth have I been bewitched? Why on earth have I been bewitched? What on earth is he doing on a two-masted warship? As a philosopher! A physicist! A poet! A swordsman! A musician! An aerial traveler! A debater who argues needle to needle! He can do anything. As the supreme... but... yet he achieves nothing... ...Yes, you guys want to take everything from me! ...Come on, take it, just take it... But... no matter how you shout, on the road to the new world, I will still take one thing with me! Let me see your strong heart! That’s right, the plume on your hat! The emblem of courage in your heart... the plume on your hat! Sorry, I have to go. I can’t keep people waiting! Look... the moon has come to greet me! Mon panache! ![](https://cdn.luogu.com.cn/upload/pic/21106.png) I step into the air. The two of them desperately try to pull me back. But I step into the air. That’s right. For a brand-new world, I will fall from the sky. To gain new power. For a new truth. I take this step. From my hands, I feel the trembling of the two of them. It’s okay... I am by your side! Sora! ![](https://cdn.luogu.com.cn/upload/pic/21109.png) I throw myself completely into the air. My body instantly falls from the air toward the ground. I tightly grip their wrists and pull them along. Seeing their expressions... They cry and laugh at the same time... They seem very scared... yet also seem very happy... Ah... What is this? Flying feels so comfortable. As if I have become an angel... Such fast speed... Such fast wind... But I can’t hear any sound... The world is turning quietly. Soon, we are about to reach the ground... The pioneer of aerodynamics... I know that everything is turning in the sky, and the earth that embraces me. Just a little more, and I will reach the world... Just a little more, and I will reach the ground... The approaching shadow. The ground reflects my silhouette.

Description

You are enjoying HS in a galgame, but the game crashes, so you can only do a data structure problem: Maintain a sequence $a_i$ of length $n$, with $m$ operations. 1. Modify the values in interval $[l,r]$ to $x$. 2. Query how many different numbers appear in interval $[l,r]$. That is, if the same number appears multiple times, it is counted only once.

Input Format

The first line contains two integers $n,m$. The second line contains $n$ integers representing $a_i$. The next $m$ lines are either $1\ l\ r\ x$ or $2\ l\ r$, representing modification and query respectively.

Output Format

For each query, output one number as the answer.

Explanation/Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 Constraints: $1\leq n , m \leq 10^5$,$1\leq a_i\leq 10^9$。 Translated by ChatGPT 5