CF1687E.Become Big For Me

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 aa and a number vv whose initial value is 11 . She wants to make v=gcdij{aiaj}v = \gcd\limits_{i\ne j}\{a_i\cdot a_j\} by no more than 10510^5 opreations ( gcdij{aiaj}\gcd\limits_{i\ne j}\{a_i\cdot a_j\} denotes the gcd\gcd of all products of two distinct elements of the sequence aa ).

In each operation, she picks a subsequence bb of aa , and does one of the followings:

  • Enlarge: v=vlcm(b)v = v \cdot \mathrm{lcm}(b)
  • Reduce: v=vlcm(b)v = \frac{v}{\mathrm{lcm}(b)}

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

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

输入格式

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

The second line contains nn integers a1,a2,,ana_1,a_2,\cdots,a_n ( 1ai1061\leq a_i\leq 10^6 ) — the sequence aa .

It can be shown that the answer exists.

输出格式

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

The following kk lines contains several integers. For each line, the first two integers ff ( f{0,1}f\in\{0,1\} ) and pp ( 1pn1\le p\le n ) stand for the option you choose ( 00 for Enlarge and 11 for Reduce) and the length of bb . The other pp integers of the line i1,i2,,ipi_1,i_2,\ldots,i_p ( 1i1<i2<<ipn1\le i_1<i_2<\ldots<i_p\le n ) represents the indexes of the subsequence. Formally, bj=aijb_j=a_{i_j} .

输入输出样例

  • 输入#1

    3
    6 10 15

    输出#1

    1
    0 3 1 2 3
  • 输入#2

    4
    2 4 8 16

    输出#2

    2
    0 1 4
    1 1 1

说明/提示

Test case 1:

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

Perform v=vlcm{a1,a2,a3}=30v = v\cdot \operatorname{lcm}\{a_1,a_2,a_3\}=30 .

Test case 2:

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

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

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

首页