Hello guys.
I was trying the problem https://mirror.codeforces.com/contest/182/problem/D
The intended complexity of my solution is supposed to be $$$O(n\sqrt{n})$$$ but somehow I was repeatedly getting TLE. When I switched the concerned part where I was using + for concatenation of two strings with append it got accepted.
I went over to stackoverflow for figuring out the cause but I couldn't understand much of it besides trying the reserve keyword. I also tried using the reserve keyword for reserving space for the string but it resulted in TLE as well.
Here are my submissions:-
https://mirror.codeforces.com/contest/182/submission/82678284 -Using append.
https://mirror.codeforces.com/contest/182/submission/82677975 -Using + for concatenation.