Vlad Building Beautiful Array solution codeforces
Vlad was given an array 𝑎� of 𝑛� positive integers. Now he wants to build a beautiful array 𝑏� of length 𝑛� from it.
Vlad considers an array beautiful if all the numbers in it are positive and have the same parity. That is, all numbers in the beautiful array are greater than zero and are either all even or all odd.
To build the array 𝑏�, Vlad can assign each 𝑏𝑖�� either the value 𝑎𝑖�� or 𝑎𝑖−𝑎𝑗��−��, where any 𝑗� from 11 to 𝑛� can be chosen.
To avoid trying to do the impossible, Vlad asks you to determine whether it is possible to build a beautiful array 𝑏� of length 𝑛� using his array 𝑎�.
Vlad Building Beautiful Array solution codeforces
The first line of input contains an integer 𝑡� (1≤𝑡≤1041≤�≤104) — the number of test cases.
Then follow the descriptions of the test cases.
The first line of each case contains a single integer 𝑛� (1≤𝑛≤2⋅1051≤�≤2⋅105) — the length of the array 𝑎�.
The second line of each case contains 𝑛� positive integers 𝑎1,𝑎2,…,𝑎𝑛�1,�2,…,�� (1≤𝑎𝑖≤1091≤��≤109) — the elements of the array 𝑎�.
It is guaranteed that the sum of 𝑛� over all cases does not exceed 2⋅1052⋅105.
Output 𝑡� strings, each of which is the answer to the corresponding test case. As the answer, output “YES” if Vlad can build a beautiful array 𝑏�, and “NO” otherwise.
You can output the answer in any case (for example, the strings “yEs“, “yes“, “Yes” and “YES” will be recognized as a positive answer).
NO YES YES YES YES NO NO