issue in Z- Algorithm implementation

Правка en2, от Ahmed_Araby, 2019-06-03 00:01:40

I just learned Z-algorithm (string processing) and in every problem I solve on it when I start the main outer loop of the function from the index 0 I get TLE but when I start from 1 I get Accepted

for example problem 127D - Password

(here I use the algorithm for matching the string with it self to find out max length if sub string that start at any index i match a prefix of the whole string)

this submission start the loop from 0 and get TLE 54993356 but this submission start from 1 and get Accepted 54993706

and this is the only change that I made for the Accepted solution ( for(int i=1; i<n; i++) // i start form 1 instead of 0 ************************** ) you can see this in the second submission

so some one could give me a reason and tell my why this happen ? thanks in advance

Теги z-algorithm, string problem, string algorithms, implementation

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Ahmed_Araby 2019-06-03 00:02:44 6
en2 Английский Ahmed_Araby 2019-06-03 00:01:40 169
en1 Английский Ahmed_Araby 2019-06-02 23:55:34 717 Initial revision (published)