#P13802. [SWERC 2023] Team selection

[SWERC 2023] Team selection

题目描述

:::align{center}

:::

Two team leaders get to assemble their teams by choosing team members among a set of players that are numbered from 1 to NN. The leaders take turns, each picking the kthk^\text{th} player among the remaining ones, according to their ideas of which one of the remaining players would be the best addition to their teams.

Given the choices of the two leaders (the first team leader starts first), please compute the list of players in each team.

输入格式

The input consists of three lines. The first line contains the single integer NN. The second line contains N/2N/2 space-separated integers a1,a2,,aN/2a_1, a_2, \dots, a_{N/2} representing the choices of the first team leader: during the (2k1)th(2k-1)^\text{th} turn, the first leader chose the aktha_k^\text{th} remaining player. The third line contains N/2N/2 space-separated integers b1,b2,,bN/2b_1, b_2, \dots, b_{N/2} representing the choices of the second team leader: during the 2kth2k^\text{th} turn, the second leader chose the bkthb_k^\text{th} remaining player.

Limits

  • 2M4 000 0002 \leq M \leq 4~000~000;
  • NN is multiple of 2;
  • the choices of the team leaders are valid: at each step, they are between 1 and the number of remaining players (inclusive).

输出格式

The output should contain two lines, each containing N/2N/2 space-separated integers. The first line should contain the list x1,x2,,xN/2x_1, x_2, \dots, x_{N/2} of the players chosen to become members of the first team, in the order they were chosen: the player xkx_k was chosen during the (2k1)th(2k-1)^\text{th} turn. The second line should contain the list y1,y2,,yN/2y_1, y_2, \dots, y_{N/2} of the players chosen to become members of the second team, in the order they were chosen: the player yky_k was chosen during the 2kth2k^\text{th} turn.

4
1 1
2 1
1 2
3 4