Doubt in CodeForces Round 646 Div 2 problem B. Subsequence Hate

Hello, could anyone tell me why this O(N^2) solution is giving TLE on Test case 4. whereas this O(N^2) solution got accepted. the only difference between the two codes is in last for loop. In the first one, I am not creating a copy (curr) of string in the last for loop. whereas in the second code I am creating a copy of string as curr while iterating. I think the first solution should be fast than the second. what is happening here?

Again this difference is occuring due to cold war between cpp14 and cpp17 there are many conflicts in between these two versions of cpp sometimes tle/wa in one of these results AC in other at the same code.
To be clear if u will submit that tle code in cpp14 u will get an AC verdict.

1 Like

I will still suggest to prefer using O(n) solution as there was quite a high chance that O(n*n) solution would have got TLE in system test as t is 100 and n is 1000 .

My O(n) solution: Submission #82090128 - Codeforces

see this video editorial foe detail explanation of problem

thanks but i did it during the contest using dp.

1 Like