why my submission is TLE?

Revision en2, by crozzhtt, 2021-08-07 08:44:49

Hello everyone, I have 1 question for my submission to the problem: https://mirror.codeforces.com/problemset/problem/1200/E

Summary: for n strings, the task is to combine those strings into one large string, and when merging the two strings, remove the longest prefix of the second string that duplicate with the suffix of the first string.

Solution idea: I create a variable to store the resulting string after each iteration, so when it comes to the i-th string, I will compare the suffix of the resulting string with the prefix of current string by hashing. However, I don't understand why my submission gets TLE , because I think my algorithm is O(n), so I need your help. This is my TLE submission for this problem: https://mirror.codeforces.com/contest/1200/submission/125065146

Thanks a lot!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English crozzhtt 2021-08-07 08:47:50 69
en2 English crozzhtt 2021-08-07 08:44:49 10 Tiny change: ' with the current s' -> ' with the prefix of current s'
en1 English crozzhtt 2021-08-07 08:43:33 818 Initial revision (published)