[POI2009] FIB-Words 2

题意翻译

## 题目描述 下面的任务是第16届波兰语竞赛第三阶段的任务“单词”的一个明显的难度增强版本。它并没有在比赛中使用,但对于那些解决了“单词”的人来说,它是一个扩展 :) 。 函数 $h$ 作用于由数字 $0$ 和 $1$ 组成的字符串,其通过将每一个数字 $0$ 替换为 $1$,将每一个数字 $1$ 替换为字符串 $10$ 来独立且同时地变换字符串 $w$。 例如: $$h(``1001")=``101110"$$ $$h(``\ ")=``\ "$$ 其中例二即把空字符串赋值给空字符串。 注意, $h$ 是一个一对一的函数。 我们用 $h^k$ 表示函数 $h$ 使用 $k$ 次。 特别的, $h^0(w)=w$。 我们对 $k = 0, 1, 2, ...$ 的 $h^k(``0")$ 形式的字符串感兴趣,这个序列为: $$ ``0", ``1", ``10", ``101", ``10110", ``10110101", \ldots $$ 如果字符串 $x$ 在 $y$ 中以一个连续的(即一个块)子串出现,我们就称 $x$ 为字符串 $y$ 的子串。给出整数 $k_1, k_2, k_3, ..., k_n $ 的序列。你的任务是检查对于一些 $m$ 来说, $h^{k_1}(``0") \cdot h^{k_2}(``0") \cdot \ldots \cdot h^{k_n}(``0") $ 形式的字符串是否是 $h^m(``0")$ 的子串,如果有,你应该找到最小的 $m$。 ## 输入内容 输入的第一行包含一个整数 $n$, $1 \leq n \leq 1000000$。输入的第二行包含 $n$ 个非负整数 $k_1, k_2, k_3, ..., k_n $,用单个空格分隔。 ## 输出内容 您的程序应该输出 $t$ 行,每个测试输出一行。你的程序应该输出的最小非负整数 $m$,使 $h^{k_1}(``0") \cdot h^{k_2}(``0") \cdot \ldots \cdot h^{k_n}(``0") $ 是 $h^m(``0")$ 的子串。如果不存在 $m$,则输出 `NIE`(波兰语中的 _no_ )。 _Translated By in\_young\_ren_

题目背景

征求翻译。如果你能提供翻译或者题意简述,请直接发讨论,感谢你的贡献。

题目描述

The following task is a significantly harder version of task Words from the third stage of 16th Polish OI. It wasn't used in the contest itself, but is an extension for those who solved "Words" and want more. :-) Let ![](http://main.edu.pl/images/OI16/fib-en-tex.1.png) be a function acting on strings composed of the digits 0 and 1. The function ![](http://main.edu.pl/images/OI16/fib-en-tex.2.png) transforms the string ![](http://main.edu.pl/images/OI16/fib-en-tex.3.png) by replacing (independently and concurrently) every digit 0 with 1 and every digit 1 with the string ![](http://main.edu.pl/images/OI16/fib-en-tex.4.png). For example ![](http://main.edu.pl/images/OI16/fib-en-tex.5.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.6.png) (i.e. ![](http://main.edu.pl/images/OI16/fib-en-tex.7.png) assigns an empty string to the empty string). Note that ![](http://main.edu.pl/images/OI16/fib-en-tex.8.png) is an injection, or a one-to-one function. By ![](http://main.edu.pl/images/OI16/fib-en-tex.9.png) we denote the function ![](http://main.edu.pl/images/OI16/fib-en-tex.10.png) composed with itself ![](http://main.edu.pl/images/OI16/fib-en-tex.11.png) times. In particular, ![](http://main.edu.pl/images/OI16/fib-en-tex.12.png) is the identity function ![](http://main.edu.pl/images/OI16/fib-en-tex.13.png). We are interested in the strings of the form ![](http://main.edu.pl/images/OI16/fib-en-tex.14.png) for ![](http://main.edu.pl/images/OI16/fib-en-tex.15.png) This sequence begins with the following strings: ![](http://main.edu.pl/images/OI16/fib-en-tex.16.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.17.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.18.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.19.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.20.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.21.png). We call the string ![](http://main.edu.pl/images/OI16/fib-en-tex.22.png) a substring of the string ![](http://main.edu.pl/images/OI16/fib-en-tex.23.png) if it occurs in ![](http://main.edu.pl/images/OI16/fib-en-tex.24.png) as a contiguous (i.e. one-block) subsequence. A sequence of integers ![](http://main.edu.pl/images/OI16/fib-en-tex.25.png) is given. Your task is to check whether a string of the form ![](http://main.edu.pl/images/OI16/fib-en-tex.26.png) is a substring of ![](http://main.edu.pl/images/OI16/fib-en-tex.27.png) for some ![](http://main.edu.pl/images/OI16/fib-en-tex.28.png), and if it is, you shuold find minimal such ![](http://main.edu.pl/images/OI16/fib-en-tex.29.png).

输入输出格式

输入格式


The first line of the standard input contains a single integer ![](http://main.edu.pl/images/OI16/fib-en-tex.30.png), ![](http://main.edu.pl/images/OI16/fib-en-tex.31.png). The second line of standard input holds ![](http://main.edu.pl/images/OI16/fib-en-tex.32.png) non-negative integers ![](http://main.edu.pl/images/OI16/fib-en-tex.33.png)(![](http://main.edu.pl/images/OI16/fib-en-tex.34.png)), separated by single spaces.

输出格式


Your programme should print out ![](http://main.edu.pl/images/OI16/fib-en-tex.35.png) lines to the standard output, one for each test unit. Your programm should print to standard output minimal non-negative integer ![](http://main.edu.pl/images/OI16/fib-en-tex.36.png), such that ![](http://main.edu.pl/images/OI16/fib-en-tex.37.png) is a substring of ![](http://main.edu.pl/images/OI16/fib-en-tex.38.png), or NIE (no in Polish) if such ![](http://main.edu.pl/images/OI16/fib-en-tex.39.png) doesn't exist.

输入输出样例

输入样例 #1

2
1 2

输出样例 #1

4