Hey there Codeforces!

I was trying to solve the C problem in Codeforces Testing Round #1.

I knew that so many people solved it using binary tree but I wanted to try another aproach. I tried to solve it using SQRT Decomposition. I've got so many wrong answers and altough I've worked on it for like 2 days I couldn't fix the problem. Can you please help me about that?

My code is this.

If you find any bugs or if you have any suggestions I would appreciate it.

Thank you already!

Auto comment: topic has been updated by heysem (previous revision, new revision, compare).Dude,you r trying to solve 2200 rating problem?I mean how in the world?No wonder you get so many WA.You didn't even reach cyan or blue. Pardon me if it's not your real account or you are different than most of us.

I'm trying to solve this question to consolidate the SQRT decom data structure.

This question is from a teacher advice.

This is the first or second problem you encounter when you learn SQRT Decomposition. So nothing surprising.

Bruh, in an online national camp which excludes IOIers, we are solving a lot of problems from range 2000-2500. In that camp, people's ratings range from grey to purple so it is really okay to solve a problem which is a lot larger than your rating. In IOI camp, there was a problem which was 2900. Does that mean we are not allowed to know its solution or think about its solution? For sure no. Also, this 2200 problem is a fake 2200 as it was in a testing round. I would give it meh, 1800 or maybe less as it is a standard problem.

Thank you, thats what I'm talking about.

Problem solved! It appears to be a bug with circular situations.