Problem D
Martian DNA
For martians, however, things are a bit different; top
secret research conducted on the martian that was recently
captured by NASA, revealed that its DNA consisted of a whopping
A certain research group interested in exploiting martian
DNA in artificial intelligence applications has requested to
get a single consecutive piece of the martian DNA string. For
For reasons related to computational complexity, they prefer the shortest substring of the DNA which satisfies their requirements. Your job is to find it.
Input
The first line contains three integers
The second line contains
Each of the following
Output
Output a single integer, the length of the shortest consecutive substring of the DNA that satisfies the researchers’ requirements. If no such substring exists, output “impossible”.
Sample Input 1 | Sample Output 1 |
---|---|
5 2 2 0 1 1 0 1 0 1 1 1 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
13 4 3 1 1 3 2 0 1 2 0 0 0 0 3 1 0 2 2 1 1 2 |
7 |
Sample Input 3 | Sample Output 3 |
---|---|
5 3 1 1 2 0 1 2 0 2 |
impossible |