I am continuously getting TLE on "substring search" (question 1 of step 3 ). I tried declaring global variables, tried passing reference to vectors, reduced function calls but nothing worked. According to me, my code is O(nlogn). Can someone please help me in finding why I am getting TLE. Here is the code: https://mirror.codeforces.com/edu/course/2/lesson/2/3/practice/contest/269118/submission/85793528
Submissions in the EDU section are private, so people cant view your submissions.
So what do I do?
Use pastebin and post your submission link.
https://pastebin.com/Sj47Zwhv This is the link
Creating (multiple) substr's per check is expensive as it involves allocation and copying of the substring.
The compare function has overloads that take start + length so you can compare the strings without creating a substr.
Finally got accepted. I didn't realize that substr would be that expensive. Thanks a lot.