No.3487 Restricted Shiritori
Problem Statement
You are given lowercase English letters $s$ and $e$, and a positive integer $N$.
Output one string of $N$ lowercase English letters that starts with $s$ and ends with $e$.
If no such string exists, output -1.
Input
$s$ $e$ $N$
- $s$ and $e$ are each a single lowercase English letter
- $1 \leq N \leq 10$
- $N$ is an integer
Output
If there are multiple answers, output any one of them.
If no answer exists, output -1.
Sample
Sample 1
Input
c t 3
Output
cat
cat is a string of $3$ lowercase English letters that starts with c and ends with t.
Sample 2
Input
q g 10
Output
qawsedrftg
The string does not have to be a word found in a dictionary.
Sample 3
Input
s h 1
Output
-1
There is no string of $1$ lowercase English letter that starts with s and ends with h.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
UT0911