Блог пользователя t_t_m

Автор t_t_m, история, 2 года назад, По-английски

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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The solution I can think of is rather advanced, it involves linear-time string matching (KMP or Rabin-Karp) and matrix exponentiation.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 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.