eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Martians` DNA Analysis

Martians` DNA Analysis

After recent disciveries of remains of ancient Martian civilization, many biology specialists lay their hopes to DNA analysis of Martians. The task is complicated by the fact that unlike human DNA that only contains four nucleotides, Martians must have had more advanced organisms, so their DNA contains upto \textbf{36} nucleotides. One step of analysis is detecting blocks that are repsonsible for some particular organism properties. But how can one identify complete blocks? One way to do so, is to search for so called \textit{maximal repetitions}. Let us consider DNA as a string\textbf{ω}, where each character identifies some nucleotide. A non-empty substring of the string is called a maximal repetition if it is both \textit{left-branching} and \textit{right-branching}. The string \textbf{α} is called left-branching there are two different characters \textbf{c_1} and\textbf{c_2}, such that both \textbf{c_1α} and \textbf{c_2α} are substrings of \textbf{\$ω} (here '\textbf{\$}' is a character that does not occur in \textbf{ω}, it is introduced so that string that is prefix of \textbf{ω} and occurs somwhere else in it were left-branching). Similarly, \textbf{α} is right branching if both \textbf{αc_1} and \textbf{αc_2} are substrings of \textbf{ω\$} for some different \textbf{c_1} and \textbf{c_2}. Long maximal repetitions are good candidates for complete blocks. Given a string that represents a Martian’s DNA, find the number of different (as strings) maximal repetitions in it, the length of the longest maximal repetition in it, and the number of its longest maximal repetitions. \InputFile Input file contains non-empty string that contains only capital latin letters and digits and represents a Martian’s DNA. The length of the string does not exceed \textbf{6000}. \OutputFile Output the number of maximal repetitions in the DNA, the length of its longest maximal repetition, and the number of maximal repetitions that have this length. If there are no maximal repetitions, output three zeroes.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
ABCBABCA
Выходные данные #1
3
3
1

Объяснение: In the example strings “A”, “AB”, “ABC”, and “B” are left-branching, strings “A”, “ABC”, “B”, and “BC” are right-branching, so strings “A”, “ABC”, and “B” are maximal repetitions. The longest of them is “ABC”, its length is 3, there is only one maximal re

Источник Russian Teams Training Sessions in Petrozavodsk, Summer 2004, Andrew Stankevich Contest 8, Thursday, August 26, 2004