No.8081 HQ9+
タグ : / 解いたユーザー数 53
作問者 :
%20
Problem Statement
You are given a string $S$ of length $N$. Each character of $S$ is an uppercase or lowercase letter. Create and output a single-line HQ9+ source code that outputs the string $S$.
If no such source code exists, output -1 instead.
*For HQ9+, read this page or check the implementations in C++ or Python3 below.
Note that the C++ code or the Python3 code at the links below is considered to be the HQ9+ implementation used. It is guaranteed that an answer to this problem, if one exists, behaves identically under either implementation.
Importantly, in the implementations used here, HQ9+ source code is recognized only up to just before the first newline. For code spanning two or more lines, only the part up to just before the newline of the first line is read, and the string output by the Q command also consists of only that part.
Therefore, if there exists an HQ9+ source code that outputs the string $S$ when run with these implementations, then a single-line one always exists as well.
Input
$N$ $S$
$1 \le N \le 10^5$
$N$ is an integer.
$|S|=N$
Each character of $S$ is an uppercase or lowercase letter.
Output
Output, on a single line, an HQ9+ source code that outputs the string $S$ when run with the implementation specified in the problem statement, followed by a newline.
Sample
Sample 1
Input
1 Q
Output
Q
The Q command outputs the source code itself. This is "Q", which matches the input string.
Sample 2
Input
3 abc
Output
-1
It can be shown that no HQ9+ source code outputs only the string "abc".
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。