#K62712. Team Formation from Participants
Team Formation from Participants
Team Formation from Participants
You are given a list of participant IDs and the number of participants n. Your task is to form teams by pairing consecutive participant IDs from the given list. If the number n is even, you should form n/2 teams (each team is a pair of two participants). If the number n is odd, it is impossible to form teams so you should output Not possible
.
Note: The participants are paired in the order they appear. For example, if the participant IDs list is [1, 2, 3, 4], the teams are (1, 2) and (3, 4). When there are zero participants (n = 0), simply output nothing.
The expected output should be printed to standard output, where each team is printed on a separate line with the two numbers separated by a space. In the case where pairing is not possible, print exactly Not possible
(without quotes).
inputFormat
The input is given from standard input and consists of two lines.
- The first line contains a single integer n (0 ≤ n ≤ 105), representing the number of participants.
- If n is greater than zero, the second line contains n space-separated integers representing the participant IDs.
outputFormat
If n is even, output n/2 lines where each line contains two space-separated integers denoting a team formed by consecutive participants. If n is odd, output a single line with the string Not possible
. In the case of n = 0, output nothing.
4
1 2 3 4
1 2
3 4
</p>