CF BETA 90 problem D — Z algorithm

Revision en1, by _kryptonyte_, 2015-07-13 06:07:59

I am having problem with this problem. http://codeforces.com/problemset/problem/119/D [](http://codeforces.com/problemset/problem/119/D)

Here is my solution , http://ideone.com/2Cz6rV [](http://ideone.com/2Cz6rV)

I don't know why it gives me WA on test case 36. the test case is big so i can't debug it. Can anybody tell me what's the problem. I am using Z algorithm.

The Idea is, (two string is concatenated with '\x7F' hexadecimal value) 1. Calculate z value for b+a ==> value goes to zba 2. Calculate z value for a+reverse(b) ==> value goes to zarb 2. Calculate z value for reverse(a)+b ==> value goes to zrab

then iterate through zba( from b.size()+1 to the end ) Calculate (i,j) stated in the problem. Check (0...i) string from zarb[] and check (j..n-1) from zrab[].

Tags #zalgorithm, hashing, kmp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English _kryptonyte_ 2015-07-13 06:13:15 6
en4 English _kryptonyte_ 2015-07-13 06:12:23 29
en3 English _kryptonyte_ 2015-07-13 06:11:14 39
en2 English _kryptonyte_ 2015-07-13 06:09:48 159
en1 English _kryptonyte_ 2015-07-13 06:07:59 908 Initial revision (published)