Comments

But for more hard queries, you can use, for example:

  1. treap
  2. split&rebuild sqrt-decompositon
  3. split&merge sqrt-decomposition

I think the simplest solution is using something like sqrt-decomposition. (https://cp-algorithms.com/data_structures/sqrt_decomposition.html)

Divide an array into $$$k$$$ blocks and precalculate answer in block.

To delete an element, you need to find his block and his position in block and just erase. After that, recalculate block's answer.

To answer the query, you should find position of left and right elements of the query and then answer like in sqrt-decomposition.

Here is a code: https://pastebin.com/m4s37RdD

I know that i'm not so good at cp, but I have some advices that can help you:

  1. Not to cheat. As some people (almost everyone) here noticed, your code is suspicious (but if you wasn't cheating except one contest that was skipped, I apologize).

  2. Not to write comments at cf rounds. It is unnecessary and it is a waste of time (unless you used AI).

  3. Not to worry so much about cf rating. Just enjoy problems.

  4. Solve more cf problems.

  5. Not to write strange lines like you did at this round.

I hope it will help you.

Yeah))

Also he/she has skipped round)

But it's really strange that such suspicious code wasn't banned

I think the problem is in this line (at least at this contest):


if(t==567) cout<<"yayayayayyaya"<<'\n';