No.8042 Bookshelf
タグ : / 解いたユーザー数 229
作問者 :
259_Momone
Problem Statement
Sort the books on the bookshelf in lexicographical order of their titles $S$ and output them one per line. If there are multiple books with the same title, arrange them in the order given by their corresponding $id$, where $"iti","ni","san","yon"$ represent $1,2,3,4$ respectively.
A "par" has been set for each language. If you have spare time, try shortening your code. Submissions exceeding these values can still get AC without any problem.
C++(GCC):150Byte
C(GCC):120Byte
Python3:55Byte
Ruby:26Byte
Perl:15Byte
Bash:9Byte
Haskell:65Byte
PHP:70Byte
No par is set for languages not listed above.
Input
$N$ $S_1 \quad id_1$ $S_2 \quad id_2$ $:$ $S_N \quad id_N$
$1 \le N \le 50$
$1 \le |S_i| \le 25 \quad(1 \le i \le N)$
$S_i$ consists only of lowercase letters$\quad(1 \le i \le N)$
$id_i \in \{"iti","ni","san","yon"\} \quad(1 \le i \le N)$
If $i \ne j$, then $(S_i,id_i) \ne (S_j,id_j) \quad (1 \le i,j \le N)$
Output
Output the title and $id$ of each book, separated by a space, one book per line, with the books sorted by lexicographical order of title, then by $id$.
Print a newline at the end.
Sample
Sample 1
Input
3 c iti b iti a iti
Output
a iti b iti c iti
In lexicographical order, the book titled a comes first. All of them were volume 1.
Sample 2
Input
4 text ni text yon text san text iti
Output
text iti text ni text san text yon
There were volumes 1 through 4 of the book titled text.
Sample 3
Input
3 abc iti abcd ni abc san
Output
abc iti abc san abcd ni
Instead of volume 2 of abc, there is volume 2 of abcd. Perhaps it was bought by mistake.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。