Problem F
A Random Problem
Generating a random number sequence is not easy. Many
sequences may look random but upon closer inspection we can
find hidden regularities in the occurrence of the numbers. For
example, consider the following
4 7 9 5 9 3 5 0 0 1 7 8 5 0 2 6 3 5 4 4 4 6 3 3 2 7 1 8 7 8 7 6 1 1 7 2 5 4 7 2 0 4 4 5 8 3 0 6 9 3 2 6 6 8 5 2 5 1 2 7 2 4 1 0 0 4 9 1 8 7 5 0 4 4 8 4 3 2 6 8 8 5 6 7 0 9 7 0 3 6 1 4 4 1 2 3 2 6 9 9
If you look closely, whenever a
-
any time there is an
followed locations later by a there is always a located locations after the unless ’s location is within distance of the end of the sequence. -
any time there is a
followed locations later by a there is always an located locations before the unless ’s location is within distance of the beginning of the sequence. -
any time there is an
followed locations later by a there is always a located locations after the . -
the correlation occurs at least
times, where denotes the smallest integer greater than or equal to .
Such correlations are tough to spot in general, so that’s where we need your help. You will be given a sequence of digits and must search it for triple correlations.
Input
Input starts with a positive integer
Output
Display triple correlation a(n)b(m)c found if it occurs in the list (with the appropriate values for a, b, c, n, and m filled in) or the phrase random sequence otherwise. If there are multiple triple correlations in the sequence, display the one which begins earliest in the sequence. If there is still a tie, choose the one with the smaller value of n, and if there is still a tie, choose the one with the smaller value of m.
Sample Input 1 | Sample Output 1 |
---|---|
100 4 7 9 5 9 3 5 0 0 1 7 8 5 0 2 6 3 5 4 4 4 6 3 3 2 7 1 8 7 8 7 6 1 1 7 2 5 4 7 2 0 4 4 5 8 3 0 6 9 3 2 6 6 8 5 2 5 1 2 7 2 4 1 0 0 4 9 1 8 7 5 0 4 4 8 4 3 2 6 8 8 5 6 7 0 9 7 0 3 6 1 4 4 1 2 3 2 6 9 9 |
triple correlation 4(1)4(3)3 found |
Sample Input 2 | Sample Output 2 |
---|---|
10 1 2 3 1 2 2 1 1 3 0 |
random sequence |