#4534. Qualification Contest
Qualification Contest
Qualification Contest
题目描述
There were participants in a contest. The participant ranked -th had the nickname .
Print the nicknames of the top participants in lexicographical order.
什么是字典顺序?
简单来说,字典顺序就是词典中的单词排列顺序。作为形式化描述,下面给出对不同字符串 和 的排序算法。
令 表示字符串 的第 个字符。我们写 若 在字典序上小于 ,写 若 在字典序上大于 。
-
令 $L$ 为 $S$ 和 $T$ 中较短者的长度。对于 $i=1,2,\dots,L$,检查 $S_i$ 是否等于 $T_i$。
如果存在某个 $i$ 使得 $S_i \neq T_i$,令 $j$ 为最小的这样的 $i$。比较 $S_j$ 与 $T_j$。若 $S_j$ 在字母表中比 $T_j$ 更靠前,则 $S \lt T$;若 $S_j$ 更靠后,则 $S \gt T$。
如果不存在这样的 $i$,比较 $S$ 和 $T$ 的长度。若 $S$ 比 $T$ 短,$S \lt T$;若 $S$ 比 $T$ 长,$S \gt T$。
输入格式
The input is given from Standard Input in the following format:
输出格式
Print the nicknames, separated by newlines.
5 3
abc
aaaaa
xyz
a
def
aaaaa
abc
xyz
4 4
z
zyx
zzz
rbg
rbg
z
zyx
zzz
3 1
abc
arc
agc
abc
提示
and are integers.
is a string of length consisting of lowercase English letters.
if .This contest had five participants. The participants ranked first, second, third, fourth, and fifth had the nicknames , , , , and , respectively.
The nicknames of the top three participants were , , , so print these in lexicographical order: , , .
标签: AtCoder|abc288B
来源
AtCoder|abc288B