### t_t_m's blog

By t_t_m, history, 2 months ago,

I've stumbled upon a version of this problem with smaller constraints on another site: 177 — G2 and managed to solve it using a naive approach (I believe it'd get me 30% of the points in this version aswell).

But I really want to know the intended solution that works with such large constraints, any help is appreciated, thanks

• 0

 » 2 months ago, # |   0 The solution I can think of is rather advanced, it involves linear-time string matching (KMP or Rabin-Karp) and matrix exponentiation.
•  » » 2 months ago, # ^ |   0 If we can perform Berlekamp-Massey on the result for small fibonacci strings (at least $|s_i| \le |S| \le 10\cdot |s_i|$), the templates made for the algorithm should be able to take case of the rest.