#C1477. Splitting Teams Based on Parity
Splitting Teams Based on Parity
Splitting Teams Based on Parity
You are given a number of test cases. In each test case, you are provided with the number of participants N and a list of N integers representing the skill levels of the participants.
Your task is to split the participants into two teams:
- Team A: Participants with odd skill values.
- Team B: Participants with even skill values.
For each test case, print the skill values of Team A in the order they appear on one line, and then print the skill values of Team B on the next line. If a team has no participants, output an empty line.
The relation can be formally expressed as follows:
For each skill s in the input list,
\[ \text{Team A} = \{ s \mid s \bmod 2 \neq 0 \}, \quad \text{Team B} = \{ s \mid s \bmod 2 = 0 \} \]Follow the standard input/output format as described below.
inputFormat
The input is read from standard input (stdin) and has the following format:
T N₁ s₁ s₂ ... sₙ₁ N₂ s₁ s₂ ... sₙ₂ ... N_T s₁ s₂ ... sₙ_T
Here, T
(an integer) is the number of test cases. For each test case, N
is the number of participants, followed by N
space-separated integers representing the skill levels.
outputFormat
For each test case, output two lines:
- The first line contains the skill levels in Team A (odd numbers) separated by a single space.
- The second line contains the skill levels in Team B (even numbers) separated by a single space.
If a team has no participants, output an empty line for that team.
## sample3
5
2 3 4 5 6
4
7 8 9 10
6
1 14 15 16 17 18
3 5
2 4 6
7 9
8 10
1 15 17
14 16 18
</p>