Problem B
Raid Teams
There is an upcoming raid event in an online game. You are
the leader of a guild with
-
Amongst all currently available adventurers, the adventurer with the highest
value for the first skill is selected. In cases of ties, the adventurer with the lexicographically smallest name is selected. That adventurer is no longer available from now on. -
The same selection criteria is applied for the second and third skill in order.
-
These three adventurers will form a raid team.
-
The process repeats starting from the first skill until no more teams of three can be formed. There could be situations where some players are not part of any raid teams. They will stay behind and guard the guild hall during the event.
Report the members of every newly-created raid team, in the
order which the teams were formed. All
Input
The first line of the input contains an integer
Output
Whenever a raid team is formed, on a new line, output the three names of the adventurers of the new team from the lexicographically smallest name to the lexicographically largest name, with a single space between consecutive names.
Subtasks
-
(
Points): , all adventurers have the same skill values for all three skills. -
(
Points): -
(
Points): No additional constraint.
Warning
The I/O files are large. Please use fast I/O methods.
Sample Input 1 | Sample Output 1 |
---|---|
6 player1 3 3 3 player2 6 6 6 player3 5 5 5 player4 2 2 2 player5 1 1 1 player6 4 4 4 |
player2 player3 player6 player1 player4 player5 |