can anyone plz point out the mistake in this question of encoder contest

ques link: https://www.codechef.com/ENCO2018/problems/PNTWLL
soln link: https://www.ideone.com/dKXtES

i am certain that my approach is fine just can’t figure out what’s wrong plz help

Even I had the same problem…

Try this test case :

1

5 4

5 4 3 3 2

1 2 3 4 2

your code gives 4…expected is 3…as we need to count unique colors on wall (even if they are in different partition)
Just add a set to get correct answer…

ohh! okay thank u so much!!

//