Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.
2034A — King Keykhosrow's Mystery
Video
2034B — Rakhsh's Revival
Video
2034C — Trapped in the Witch's Labyrinth
Video
2034D — Darius' Wisdom
Video
2034E — Permutations Harmony
Video
@Update: I figured it out what was wrong, after resolving, I found that it is a wrong approach, as it is taking care of only three cycles which will fail for below test case.
0 2 0 2 1 0 1 0
Can anyone tell me why I'm getting TLE, For Problem D.
Idea behind the solution is to sort first 1 and 2, using two pointer approach, then sort 0 and 1 using two pointer approach and then one more time check again 1 and 2 if they are sorted or not using same approach.
So, in worst case I'm traversing the whole array 3 times and it is given that sum of n over all test cases do not exceed 2*10^5.
So, maximum number of iteration for worst test case will be 3*2*10^5 < 10^8, then how tle is coming as response. Below is my code.