# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Miguel is ready to build his dream house in honor of his great grandfather Hector. There is an Array of Length N containing the heights of N bricks. Each integer A_{i} denoting the height of i-th brick. Miguel will choose a range of bricks so that his great grandmother Mamá Imelda will be happy. She will be happy if the range contains every distinct height even number of times.

Miguel wants to make his great grandmother and great grandfather happy. He is little busy in some works. So he gives the problem to "MBSTU CSE Victory Day Contest 2020". He will ask Q query. In each query, you will be asked either update or delete any brick or check whether the range contains every distinct height even number of times from index L to index R (inclusive).

First line contains two integers N, Q(1 <= N, Q <= 10^{5})

Next Line contains N space separated integer denoting height of ith type brick (1 <= A_{i} <= 2* 10^{6})

Next Q lines each contain a query of the following list:

• 1 id X (update index id of brick array A with X ) (1 <= X <= 2* 10^{6})

• 2 id (delete index id of brick array A)

• 3 L R (check whether the range contains every distinct height even number of times from index L to index R)

**Here, the first index is considered as 1.**

It is guaranteed that There is no such query that brick array length will become 0.

1 <= L, R <= Current_Brick_Array_Length

For each query of 3rd type, print one line denoting that if the range is Happy , print "Happy" otherwise "Unhappy".

Input | Output |
---|---|

5 3 1 2 1 2 1 3 1 2 2 3 3 1 4 | Unhappy Happy |

Given Brick List is : 1 2 1 2 1 For the first query , range 1-2 contains both 1 and 2 one time . the range is “Unhappy”. |

70% Solution Ratio

dipubalaEarliest,

AungkurFastest, 0.1s

shojib_muLightest, 8.7 MB

RamprosadGShortest, 2466B

Login to submit