Memory limit exceeded on 535D

Revision en1, by code_kit, 2017-12-15 22:06:37

Hi guys, Am trying to solve this problem http://codeforces.net/problemset/problem/535/D. My algorithm is create a string which fits the given condition. i.e. vector of vector of chars. And use the Z algorithm to compute the longest prefix starting from the indexes given in the statement and check if it is atleast as length as p. But to my suprise i am getting memory limit exceeded on test 3 and i could not figure out what is going on here. Can someone plz tell me. My solution is https://ide.geeksforgeeks.org/9nrDUDjby6. Thanks

Tags #strings, z algorithm, kmp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English code_kit 2017-12-15 22:06:37 561 Initial revision (published)