P16441 [XJTUPC 2026] Live Streaming Awards

Background

You often recall the past. Moments of life freeze in your mind. You cut, fold, curl, and knead the time behind you into white clouds in the sky. Time is cut, folded, and curled. Huh, it seems you are not on the contest site of the Joint NOI Qualifier 2025. Where should you stay? You ask yourself. As time goes by, Xiao Z and Xiao J will also drift apart. The way you and someone stay connected is to remember, nothing more. Time passes, and Xiao Z and Xiao J will meet again. Looking back, everyone has lived the life they wanted. Something seems wrong. Huh, it seems you are also not on the contest site of NOI2024. Where should you stay? You ask yourself. NOI2233 is about to be held. To make it more enjoyable to watch, FFC decides to announce each contestant’s score one by one, and live stream the real-time award cutoff line. You finally figure it out. This year you have just entered Grade 7, and you are at the CSP-J 2020 contest. The second problem is called “[Live Streaming Awards](https://www.luogu.com.cn/problem/P7072)”. Since you could not do bucket sort, you got a high score of 95 points on this problem. Huh, how did you foresee your score on “Live Streaming Awards”? Is this really possible? Can this be done? The annual XJTUPC is going to be held again, but the veteran weak problemsetter “Xiao Biaozhun”, a catgirl, suddenly has something urgent to do and needs to return to Jianjiang. It turns out you have already retired. You are sitting at the XJTUPC2026 contest, solving a problem called “Live Streaming Awards”. Where should you stay? You ask yourself.

Description

You are playing a game known as “ZJOI2022”. The game takes place in a fantasy world called “Jianjiang”. You will play a mysterious character named “Zake”. During your free journey you will meet companions with different personalities and unique abilities, fight powerful enemies with them, and find your lost family—at the same time, you will gradually uncover the truth of “Jiutiao Kelian”. After finishing the game, each player has four attributes: - Game UID. The game UID is the unique identifier of each player, and is a positive integer. All players have different UIDs. - The element used to play the game. The element is either “Yin” or “Yang”. - The in-game guild. Each player belongs to a guild, identified by a positive integer. - Game score. The game score is a positive integer. **It is guaranteed that all players’ scores are different.** This game uses a very special settlement method. Specifically, the “judge” will reveal each player’s total score in increasing order of UID. After a player’s score is revealed, the winner list of the “Jianjiang Provincial Team” will be updated accordingly. The “Jianjiang Provincial Team” consists of Team A and Team B, and the two teams have no overlapping members. Based on all currently revealed players, update the “Jianjiang Provincial Team” list according to the rules below. **Rule 1: Selecting Team A** Let the set of currently revealed players be $S$. Denote the size of $S$ by $|S|$. Team A can contain at most $5$ players. Let the set of players in Team A be $A$, determined by the following steps: - If $|S| \le 4$, then $A = S$. - If $|S| \ge 5$, then: - Sort the players in $S$ by score from high to low, and take the top $5$ players to form a set $T$. - If $T$ contains both elements “Yin” and “Yang”, then $A = T$. - Otherwise, all players in $T$ have the same element $x$ (i.e., all “Yin” or all “Yang”). In this case: - Take the top $4$ highest-scoring players among those in $S$ whose element is $x$, and denote this set by $A_x$. - Take the highest-scoring $1$ player (if any) among those in $S$ whose element is the other element $y$ ($y \neq x$), and denote this player by $a_y$. - If $a_y$ exists, then $A = A_x \cup \{a_y\}$; otherwise $A = A_x$. **Rule 2: Selecting Team B** After determining Team A, select Team B from the remaining players $S \setminus A$. Team B can contain at most $12$ players. Let the set of players in Team B be $B$, determined by the following steps: - Sort the players in $S \setminus A$ by score from high to low to obtain an ordered list. - Initialize $B$ as empty, and record, for each guild, the current number of selected players in the provincial team ($A \cup B$). - Traverse each player in the list in order: - If the current size of Team B has reached $12$, stop selecting. - Otherwise, check the player’s guild. If the current number of players from this guild in the provincial team is **strictly less than** $5$, add this player to Team B and update the guild count; otherwise skip this player and continue to the next one. - The selection ends when the list is fully traversed or Team B reaches $12$ players. You need to output the current “Jianjiang Provincial Team” list after each player’s score is revealed. You need to output the UIDs of all players in the current “Jianjiang Provincial Team” list, arranged in the following order: - Output all UIDs of Team A first, then all UIDs of Team B. - Within the same team, output UIDs in increasing order.

Input Format

The first line contains a positive integer $n$ ($1\le n\le 100$), indicating the number of players in the game. The next $n$ lines describe the players. Line $i$ contains three integers $x_i, y_i$ and $z_i$ ($0\le x_i\le 1, 1\le y_i\le n, 1\le z_i\le 10^9$), separated by a single space, representing one player’s information. Specifically: - The game UID is $i$. - If $x_i=0$, the element used is “Yin”; if $x_i=1$, the element used is “Yang”. - The in-game guild ID is $y_i$. - The game score is $z_i$. It is guaranteed that all players’ scores are different.

Output Format

Output a total of $n$ lines. Line $i$ contains several integers separated by a single space, representing the UIDs of all players in the “Jianjiang Provincial Team” list after the scores of the first $i$ players have been revealed. In each line, output all UIDs of Team A first, then all UIDs of Team B. Within the same team, output UIDs in increasing order.

Explanation/Hint

Translated by ChatGPT 5