Comments

Never mind, it's fine.

thanks, using a 2D vector instead of map worked. i know this improves cache coherence and also vectors are easier for the runtime to work with as maps have lot of attributes for each node like color. But, in many questions i used datastructures indiscriminately but never got any TLE. i remember once using a vector of sets too.

consider these sequence of operations. lets refer to queues using 0-based indexing.

1st operation can be applied on any queue.let's say on queue 0.

i=2, we service queue 3(last one). this will reset it from 3(1+2) to 0. and we leave it untouched afterwards. therefore, there will be 2 people in it towards the end.

i=3, we service queue 1, this will reset it from 13(1+9+3) to 0. and we leave it untouched afterwards. therefore, there will be 1 person in it towards the end.

the last operation can be applied on either queue 0 or queue 2, doesn't matter as we want a zero anyways.lets say we apply it on 2.

so final count will be. 21 from q0 , 1 from q1 , 0 from q2 , 2 from q3. therefore MEX is 3.

the flaw in your code is this. when you have 2D array of all 1's then set s will only have a single element n. but in this case the answer should be n, your code would output 1.

can anybody explain why i am getting a Tle for this submission of mine 304236998 for the problem D.

doesn't the approach provided here using tree also have to go through all the alive monsters for each of the round .Or have i misunderstood the solution provided here?

why is my code for problem D 242468805 getting a time limit exceeded signal ? shouldn't it be faster than this approach using sets?