#### Topic: Country security police :)

Prompt: what idea of the decision? I started to "dig" aside  trees. Can eat  the best approach to the decision? The country Unljandija security police received an interesting signal from a space which it is possible to present in the form of sequence from 0 and 1. Before workers of this service at once there was a question: somehow to decode this message. Before decoding it has been decided to analyze the received sequence. The estimation consisted in that in the specified sequence from 0 and 1 to find such subsequences which repeat more often. Restrictions: an amount of characters in a subsequence should awake in limits from And to In inclusively. Required sequences should be no more N. The input data the Input file contains Numbers And, In, N, each of which is written down in a new line. The fourth line is contained by the message which record comes to an end with digit 2. The size of an input file no more than 2 MB. 1<=A<=12, 1<=B<=12, 1<=N<=20 the Source file contains a format of result no more N lines, in each of which the following data is written down through a gap: 1. An amount of entrances of the found subsequence (subsequences if some the different meet an identical amount of times). 2. Sequence (subsequences are written down through a gap, without duplication). Sorting: * In the lines the first to specify subsequences which meet more often and further on decrease. * if some subsequences, in which identical amount of entrances first to specify in what  an amount of characters are found. If an amount of characters it is identical, the first to specify what meet earlier at message reading from left to right. input.txt 4 5 4 11111111111111011100111111111111111112 output.txt 25 1111 23 11111 2 1110 0111 1 11110 11101 11100 11011 11001 10111 10011 01111 01110 00111 1101 1100 1011 1001 0011

#### Re: Country security police :)

Hello, olimp_20, you wrote: _> Prompt: what idea of the decision? I started to "dig" aside  trees. Can eat  the best approach to the decision? Pay attention: _> 1<=A<=12, 1<=B<=12 I.e. subsequences long no more than 2^12. It is quite possible to get an array of counters such are long, and "in a forehead". A position of the first entrance, (for sorting of results) we fulfill the second pass of an array. Complexity O (2 ^ (B)) +O (it is long sequences) For optimization: to overtake an array of zero and  at once in an array without-sign whole and to work as shifts and masks.