#P16346. Impossible Problem

    ID: 18428 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>贪心构造分类讨论

Impossible Problem

Background

Source of this problem: https://www.luogu.com.cn/contest/314899.

Problem Description

There is a sequence aa of length nn. Each time, you may choose an interval such that the sum of the numbers in this interval is odd, and then add 11 to every number in this interval.

Determine whether it is possible to make all numbers in the sequence equal.

If possible, output Yes; otherwise, output No.

Input Format

This problem has multiple test cases. The first line contains a positive integer TT.

For each testdata:

  • The first line contains a positive integer nn.
  • The second line contains nn non-negative integers representing the sequence aa.

Output Format

For each testdata:

  • Output one string on a single line representing your answer.
2
2
1 2
2
2 4
Yes
No

Hint

Constraints

For 100%100\% of the data, 1≤T≤1041 \le T \le 10^4, 1≤n≤5001 \le n \le 500, 1≤ai≤1091 \le a_i \le 10^{9}.

Test Point ID n≤n \le Score
11 1010
22
33
44
55
66
77
88
99
1010 500500

Translated by ChatGPT 5