#K43152. Shoe Pairing Problem
Shoe Pairing Problem
Shoe Pairing Problem
You are given a collection of single shoes with varying sizes. Your task is to determine whether it is possible to pair all the shoes such that each pair consists of shoes of the same size.
Formally, for each test case you are given an integer \(n\) representing the number of shoes, and a sequence \(s_1, s_2, \dots, s_n\) representing their sizes. You need to check if for every distinct shoe size, the total count is even. In mathematical notation, for any shoe size \(a\), if its frequency is \(f(a)\), then the pair can be formed if:
[ f(a) \bmod 2 = 0 ]
Print YES
if all shoes can be paired, and NO
otherwise.
Input is taken from standard input (stdin) and output is printed to standard output (stdout).
inputFormat
The first line contains an integer \(T\) representing the number of test cases. For each test case:
- The first line contains an integer \(n\) denoting the number of shoes.
- The second line contains \(n\) space-separated integers \(s_1, s_2, \dots, s_n\) representing the sizes of the shoes.
outputFormat
For each test case, output a single line containing YES
if it is possible to pair all the shoes, or NO
otherwise.
1
2
1 1
YES
</p>