GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Monday 17 October 2022

[Solution] Antifibonacci Cut Codeforces Solution



G. Antifibonacci Cut
time limit per test
12 seconds
memory limit per test
4 megabytes
input
standard input
output
standard output

Note that the memory limit is unusual.

Let's define the sequence of Fibonacci strings as follows: f0 is 0f1 is 1fi is fi1+fi2 for i>1 (+ denotes the concatenation of two strings). So, for example, f2 is 10f3 is 101f4 is 10110.

For a given string s, let's define g(s) as the number of ways to cut it into several (any number, possibly even just one) strings such that none of these strings are Fibonacci strings. For example, if s is 10110101g(s)=3 since there are three ways to cut it:

  • 101101 + 01;
  • 1011 + 0101;
  • 1011 + 01 + 01.

You are given a sequence of strings s1,s2,,sn. Calculate g(s1),g(s1+s2),,g(s1+s2++sn). Since these values can be huge, print them modulo 998244353.

Input

The first line of the input contains one integer n (1n3103).

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Then, n lines follow. The i-th line contains the string si (1|si|103), consisting of characters 0 and/or 1.

Output

Print n integers, where the i-th integer is g(s1+s2++si)mod998244353.

No comments:

Post a Comment