minipekka's blog

By minipekka, history, 2 months ago, In English

I was solving this task and now I am not able to understand what is wrong with my implementation. For those who do not know russian: you have to find all insertions of t in s and print index in s. Can you please help me?

Here is my code. Thanks.

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
2 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

There are several problems:

You should make your int h[N], p[N] to long long h[N], p[N]

In lines 23 and 26 you need multiply h[i] and hasht to P and add (s[i-'A'+1) like: h[i] = (h[i-1] * P +(s[i-1] — 'A' + 1)) % mod;

And in this problem can be letters from A-Z not only a-z. Thats why you need to do s[i-1] — 'A'