Codeforces Round 796 (Div. 1)
E
Become Big For Me
Codeforces
3500
原题
← DF →
翻译中…

Come, let's build a world where even the weak are not forgotten!—Kijin Seija, Double Dealing Characters

翻译中…

Shinmyoumaru has a mallet that can turn objects bigger or smaller. She is testing it out on a sequence $a$ and a number $v$ whose initial value is $1$. She wants to make $v = \gcd\limits_{i\ne j}\{a_i\cdot a_j\}$ by no more than $10^5$ operations ($\gcd\limits_{i\ne j}\{a_i\cdot a_j\}$ denotes the $\gcd$ of all products of two distinct elements of the sequence $a$).

翻译中…

In each operation, she picks a subsequence $b$ of $a$, and does one of the followings:

翻译中…
  • Enlarge: $v = v \cdot \mathrm{lcm}(b)$
  • Reduce: $v = \frac{v}{\mathrm{lcm}(b)}$
翻译中…

Note that she does not need to guarantee that $v$ is an integer, that is, $v$ does not need to be a multiple of $\mathrm{lcm}(b)$ when performing Reduce.

翻译中…

Moreover, she wants to guarantee that the total length of $b$ chosen over the operations does not exceed $10^6$. Fine a possible operation sequence for her. You don't need to minimize anything.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($2\leq n\leq 10^5$) — the size of sequence $a$.

翻译中…

The second line contains $n$ integers $a_1,a_2,\cdots,a_n$ ($1\leq a_i\leq 10^6$) — the sequence $a$.

翻译中…

It can be shown that the answer exists.

翻译中…

Output

翻译中…

The first line contains a non-negative integer $k$ ($0\leq k\leq 10^5$) — the number of operations.

翻译中…

The following $k$ lines contains several integers. For each line, the first two integers $f$ ($f\in\{0,1\}$) and $p$ ($1\le p\le n$) stand for the option you choose ($0$ for Enlarge and $1$ for Reduce) and the length of $b$. The other $p$ integers of the line $i_1,i_2,\ldots,i_p$ ($1\le i_1 \lt i_2 \lt \ldots \lt i_p\le n$) represents the indexes of the subsequence. Formally, $b_j=a_{i_j}$.

翻译中…

Note

翻译中…

Test case 1:

翻译中…

$\gcd\limits_{i\ne j}\{a_i\cdot a_j\}=\gcd\{60,90,150\}=30$.

翻译中…

Perform $v = v\cdot \operatorname{lcm}\{a_1,a_2,a_3\}=30$.

翻译中…

Test case 2:

翻译中…

$\gcd\limits_{i\ne j}\{a_i\cdot a_j\}=8$.

翻译中…

Perform $v = v\cdot \operatorname{lcm}\{a_4\}=16$.

翻译中…

Perform $v = \frac{v}{\operatorname{lcm}\{a_1\}}=8$.

翻译中…

样例

Input #1
3
6 10 15
Output #1
1
0 3 1 2 3
InputCopy OutputCopy
Input #2
4
2 4 8 16
Output #2
2
0 1 4
1 1 1
InputCopy OutputCopy
题目信息
题号
1687E
时间限制
3 s
内存限制
512 MB
标签
组合数学
构造
贪心
数学
数论

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