#abc304a. A - First Player

A - First Player

Score : 100100 points

问题描述

NN个人,编号为1,2,,N1, 2, \ldots, N,按照顺时针顺序围坐在一张圆桌周围。特别地,编号为11的人与编号为NN的人在顺时针方向相邻。

对于每个i=1,2,,Ni = 1, 2, \ldots, N,编号为ii的人拥有一个名字SiS_i和一个年龄AiA_i。这里,没有两个人的名字或年龄相同。

从最年轻的人开始,按顺时针顺序输出所有NN个人按照座位位置排列的名字。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN people numbered 1,2,,N1, 2, \ldots, N, sitting in this clockwise order around a round table. In particular, person 11 is sitting next to person NN in the clockwise direction.

For each i=1,2,,Ni = 1, 2, \ldots, N, person ii has a name SiS_i and an age AiA_i. Here, no two people have the same name or the same age.

Starting from the youngest person, print the names of all NN people in the order of their seating positions in clockwise order.

Constraints

  • 2N1002 \leq N \leq 100
  • NN is an integer.
  • SiS_i is a string of length between 11 and 1010, consisting of lowercase English letters.
  • ij    SiSji \neq j \implies S_i \neq S_j
  • 0Ai1090 \leq A_i \leq 10^9
  • AiA_i is an integer.
  • ij    AiAji \neq j \implies A_i \neq A_j

Input

The input is given from Standard Input in the following format:

NN

S1S_1 A1A_1

S2S_2 A2A_2

\vdots

SNS_N ANA_N

Output

Print NN lines. For each i=1,2,,Ni = 1, 2, \ldots, N, the ii-th line should contain the name of the person sitting in the ii-th position clockwise from the youngest person.

Sample Input 1

5
alice 31
bob 41
carol 5
dave 92
ellen 65

Sample Output 1

carol
dave
ellen
alice
bob

The youngest person is person 33. Therefore, starting from person 33, print the names in the clockwise order of their seating positions: person 33, person 44, person 55, person 11, and person 22.

Sample Input 2

2
takahashi 1000000000
aoki 999999999

Sample Output 2

aoki
takahashi

update @ 2024/3/10 08:32:56