#P1786. 帮贡排序

帮贡排序

Description

At present, the guild can have at most:

  • 11 guild leader (BangZhu\texttt{BangZhu}).
  • 22 vice leaders (FuBangZhu\texttt{FuBangZhu}).
  • 22 guardians (HuFa\texttt{HuFa}).
  • 44 elders (ZhangLao\texttt{ZhangLao}).
  • 77 hall masters (TangZhu\texttt{TangZhu}).
  • 2525 elites (JingYing\texttt{JingYing}).
  • Any number of regular members (BangZhong\texttt{BangZhong}).

The above positions are listed from highest to lowest.

Now absi2011 is going to adjust almost everyone’s position in the guild. He finds this difficult, so he asks you to help.

He gives you, for each person:

  • Name.
  • Original position.
  • Contribution.
  • Level.

He wants to sort everyone in the guild except the guild leader and vice leaders by the following keys:

  • Contribution (descending), primary key.
  • Order of appearance in the input (from earlier to later), secondary key.

Then update these people’s positions as follows:

  • Ranks 11 to 22: HuFa\texttt{HuFa}.
  • Ranks 33 to 66: ZhangLao\texttt{ZhangLao}.
  • Ranks 77 to 1313: TangZhu\texttt{TangZhu}.
  • Ranks 1414 to 3838: JingYing\texttt{JingYing}.
  • Ranks 3939 to (n3)(n-3): BangZhong\texttt{BangZhong}.

However, the “Le Dou” display does not sort by contribution, but by position and level.

After updating positions, output the final list as “Le Dou” would display it, sorted by:

  • Position (descending), primary key.
  • Level (descending), secondary key.
  • Order of appearance in the input (from earlier to later), tertiary key.

Note: absi2011 has no authority to adjust the positions of the guild leader or the vice leaders, including his own.

Input Format

The first line contains a positive integer nn, the number of members in Xingyue Homeland.

Each of the next nn lines contains two strings and two integers: name, position, contribution, and level.

Output Format

Output nn lines. Each line contains the name, position, and level in the order “Le Dou” displays after the adjustments.

9
DrangonflyKang BangZhu 100000 66
RenZaiJiangHu FuBangZhu 80000 60
absi2011 FuBangZhu 90000 60
BingQiLingDeYanLei HuFa 89000 58
Lcey HuFa 30000 49
BangYou3 ZhangLao 1000 1
BangYou1 TangZhu 100 40
BangYou2 JingYing 40000 10
BangYou4 BangZhong 400 1
DrangonflyKang BangZhu 66
RenZaiJiangHu FuBangZhu 60
absi2011 FuBangZhu 60
BingQiLingDeYanLei HuFa 58
BangYou2 HuFa 10
Lcey ZhangLao 49
BangYou1 ZhangLao 40
BangYou3 ZhangLao 1
BangYou4 ZhangLao 1

Hint

For 10%10\% of the testdata, n=3n=3.

For 40%40\% of the testdata, all contributions are 00.

For 100%100\% of the testdata, it is guaranteed that:

  • 3n1103 \leq n \leq 110.
  • 11 \leq name length 30\leq 30.
  • All names are pairwise distinct.
  • Names contain only visible ASCII characters.
  • 00 \leq contribution of each person 109\leq 10^9.
  • 11 \leq level of each person 150\leq 150.
  • The position is always one of the following seven:
    • BangZhu\texttt{BangZhu}.
    • FuBangZhu\texttt{FuBangZhu}.
    • HuFa\texttt{HuFa}.
    • ZhangLao\texttt{ZhangLao}.
    • TangZhu\texttt{TangZhu}.
    • JingYing\texttt{JingYing}.
    • BangZhong\texttt{BangZhong}.
  • Initially, the guild has at most:
    • 11 guild leader.
    • 22 vice leaders.
    • 22 guardians.
    • 44 elders.
    • 77 hall masters.
    • 2525 elites.
  • There is exactly one guild leader.
  • There are exactly two vice leaders.
  • Exactly one of the vice leaders is named absi2011.

Translated by ChatGPT 5