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

Automatic Input Verifier

Automatic Input Verifier

Tons and tons of programming contest problems contain integers separated with spaces and newlines in the input. In many cases, the amount of numbers found inside the file and in each particular line is determined by the numbers themselves. More formally, we define an \textit{input description} as a sequence of statements of the following types: \begin{enumerate} \item "The first/next line contains \textit{number} non-negative integer(s), \textit{variable_1}, \textit{variable_2}, ..., \textit{variable}_number.". Here, \textit{number} is a positive integer between \textbf{1} and \textbf{3}, and \textit{variable}s are arbitrary distinct variable names that have never appeared in the input description before this statement. When \textit{number} is equal to \textbf{1}, "integer(s)" should be replaced by "integer", otherwise it should be replaced by "integers". \item "The first/next line contains \textit{variable} integers.". Here, \textit{variable} is a variable name that has appeared in this description before this statement. \item "The first/next line contains a non-negative integer \textit{variable}, followed by \textit{variable} integers.". Here, \textit{variable} is a variable name that has never appeared in the input description before this statement, and will never appear in the input description after this statement. Please note that the same variable name is repeated twice in this statement. \item "The first/next line contains \textit{number} integer(s).". Here, \textit{number} is a positive integer. When \textit{number} is equal to \textbf{1}, "integer(s)" should be replaced by "integer", otherwise it should be replaced by "integers. \item "The first/next \textit{variable} lines contain \textit{number} integer(s) each.". Here, \textit{variable} is a variable name that has appeared in this description before this statement, and \textit{number} is a positive integer. When \textit{number} is equal to \textbf{1}, "integer(s)" should be replaced by "integer", otherwise it should be replaced by "integers". \item "The first/next \textit{variable_1} lines contain \textit{variable_2} integers each.". Here, \textit{variable_1} and \textit{variable_2} are (possibly the same) variable names that have appeared in this description before this statement. \item "The first/next \textit{variable_1} lines contain a non-negative integer \textit{variable_2}, followed by \textit{variable_2} integers each.". Here, \textit{variable_\{1 \}}is a variable name that has appeared in this description before this statement. \textit{variable_2} is a variable name that has never appeared in this description before this statement, and will never appear in this description after this statement, and is different from \textit{variable_1}. Please note that, unlike all other variables, \textit{variable_2} may have different values for each line described by this statement. This is useful, for example, for listing several heaps with varied amount of items in each heap. \end{enumerate} Each occurrence of "first/next" in the above statements should be subsituted by "first" in the first statement of the input description, and by "next" in all other statements. Given several input files, you need to verify whether there exists an input description containing not more than \textbf{4} statements that fits most of the given input files, and highlight the input files that don’t fit this description. \InputFile The first line of the input file contains an integer \textbf{n}, \textbf{1} ≤ \textbf{n} ≤ \textbf{10}, the number of input files given. Please note, that the meaning of words "input file" below corresponds to the second meaning of that term in this paragraph, not the first one. The description of each given input file starts with a line containing a dash ("-"). The actual given input file follows, with each line appended a exclamation mark ("!") to avoid difficulties in processing empty lines. After excluding the exclamation mark at the end, each line of each given input file will contain between \textbf{0} and \textbf{1000} integers, each between \textbf{-1000} and \textbf{1000}, separated with single spaces. Each given input file will contain at most \textbf{10000} lines and at most \textbf{100000} integers. \OutputFile In case there exists an input description with not more than \textbf{4} statements describing all given input files, output "All good!" (without quotes) to the first line of the output file, followed by the input description itself, one statement per line. Use non-empty strings of at most 10 lowercase English letters to denote variables. In case there are several possible descriptions, output any. In case there exists an input description with not more than \textbf{4} statements describing at least one given input file, find any such description that describes the most given input files. Output "Bad format: \textit{numbers}." (without quotes) to the first line of the output file, where \textit{numbers} is a single-space separated list of input file numbers that don’t fit the given input description. The input files are numbered from \textbf{1} to \textbf{n} in the order they are given. Then output the input description itself. In case no input description with not more than 4 statements fits any given input file, output "FAIL." to the only line of the output file.
Лимит времени 2 секунды
Лимит использования памяти 256 MiB
Входные данные #1
3
-
2 3!
1 2!
3 5!
-100 24!
-
5 0!
-
2 2!
2 2!
2 2!
Выходные данные #1
All good!
The first line contains 2 non-negative integers, loadljlkze, ehtmvfawjq.
The next ehtmvfawjq lines contain 2 integers each.
Автор Пётр Митричев
Источник Зимняя школа, Харьков 2011, День 8