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

Central Element

Central Element

This is an interactive problem. There is a permutation \textit{P }of numbers 1 through \textit{n}, not known to you, \textit{P }= <\textit{P}_1\textit{, P}_2\textit{, …, P_n}>. You can ask the following type of questions: Given three distinct positions \textit{i}, \textit{j }and \textit{k}, which of \textit{P_i}, \textit{P_j }and \textit{P_k }is central? Element is central if it is neither minimal nor maximal. For example, if the permutation is <2,\textit{ }1,\textit{ }4,\textit{ }3>, and you ask about positions 1, 2, and 3, you receive 2, because 2 is the central element of the set \{\textit{P}1,\textit{ P}2,\textit{ P}3\}\textit{ }= \{2,\textit{ }1,\textit{ }4\}. Note that you don't get the information at which position among 1, 2, and 3 it is located. Your task is to find the permutation \textit{P}. Actually, for each permutation \textit{P }there is a set \textit{S}(\textit{P}) of permutations that cannot be distinguished from \textit{P }using the allowed questions. You must find any permutation from this set. \Interaction First, your program must read from the standard input one line with the integer \textit{n}, the size of the permutation. The program must write to the standard output one line with three positions that you ask a question about and wait for a line in the standard input with a response, then write next question and read next response, and so on until you know the permutation \textit{P }up to \textit{S}(\textit{P}). Once you know the answer, output one line with the word ”OK” and the permutation \textit{P}. \InputFile The first line of the standard input contains \textit{n}, the size of the permutation (3 <=\textit{ n }<=\textit{ }200). Each of the next lines of the standard input contains response to your question -- the number that is central among the numbers at the asked positions. \OutputFile When you're asking questions, each line of the standard output should contain three different integers from the range of 1 to \textit{n}, space-separated. You can ask at most 2 000 questions. When you're stating the answer, the line of the standard output should contain the word ”OK”, and the numbers \textit{P}_1\textit{, P}_2,\textit{ …, P_n}, all space-separated. After printing this line your program must exit. You must flush standard output after printing each line.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
4
2 1 4 3
Выходные данные #1
0
8 questions
Автор Mikhail Dvorkin