STARTER 12 , Unexpected behavior of Codechef OJ

Hey folks, I participated in Codechef STARTER 12. On problem 4th of div 3 SPATH3 Problem - CodeChef [SPATH3 Problem - CodeChef] when i submitted it, it gave AC on 1 and TLE on 2nd Test and my code was correct. And when i submitted exact same code after contest i got submitted.
1st submit : https://www.codechef.com/viewsolution/51458293
2nd submit : https://www.codechef.com/viewsolution/51464676
Sorry for bad english as i’m not a native speaker.

Since the input was very large sometimes you can face the same issue.
Some advice prefer using ‘\n’ instead of endl bcoz endl flushes the buffer which takes time
and minimize use of * % and / in large input bcoz these arithmetic operation are costly. you can do n + n instead of 2 * n.

2 Likes

thanks man