Codeforces Round 517 (Div. 1, based on Technocup 2019 Elimination Round 2)
C
Triple Flips
Codeforces
未评级
原题
← BD →
翻译中…

You are given an array $a$ of length $n$ that consists of zeros and ones.

翻译中…

You can perform the following operation multiple times. The operation consists of two steps:

翻译中…
  1. Choose three integers $1 \le x \lt y \lt z \le n$, that form an arithmetic progression ($y - x = z - y$).
  2. Flip the values $a_x, a_y, a_z$ (i.e. change $1$ to $0$, change $0$ to $1$).
翻译中…

Determine if it is possible to make all elements of the array equal to zero. If yes, print the operations that lead the the all-zero state. Your solution should not contain more than $(\lfloor \frac{n}{3} \rfloor + 12)$ operations. Here $\lfloor q \rfloor$ denotes the number $q$ rounded down. We can show that it is possible to make all elements equal to zero in no more than this number of operations whenever it is possible to do so at all.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($3 \le n \le 10^5$) — the length of the array.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 1$) — the elements of the array.

翻译中…

Output

翻译中…

Print "YES" (without quotes) if the answer exists, otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower).

翻译中…

If there is an answer, in the second line print an integer $m$ ($0 \le m \le (\lfloor \frac{n}{3} \rfloor + 12)$) — the number of operations in your answer.

翻译中…

After that in ($i + 2$)-th line print the $i$-th operations — the integers $x_i, y_i, z_i$. You can print them in arbitrary order.

翻译中…

Note

翻译中…

In the first sample the shown output corresponds to the following solution:

翻译中…
  • 1 1 0 1 1 (initial state);
  • 0 1 1 1 0 (the flipped positions are the first, the third and the fifth elements);
  • 0 0 0 0 0 (the flipped positions are the second, the third and the fourth elements).
翻译中…

Other answers are also possible. In this test the number of operations should not exceed $\lfloor \frac{5}{3} \rfloor + 12 = 1 + 12 = 13$.

翻译中…

In the second sample the only available operation is to flip all the elements. This way it is only possible to obtain the arrays 0 1 0 and 1 0 1, but it is impossible to make all elements equal to zero.

翻译中…

样例

Input #1
5
1 1 0 1 1
Output #1
YES
2
1 3 5
2 3 4
InputCopy OutputCopy
Input #2
3
0 1 0
Output #2
NO
InputCopy OutputCopy
题目信息
题号
1071C
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。