CF1687E.Become Big For Me
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:512MB
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 a and a number v whose initial value is 1. She wants to make v=i=jgcdai⋅aj by no more than 105 operations (i=jgcdai⋅aj 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⋅lcm(b)
- Reduce: v=lcm(b)v
Note that she does not need to guarantee that v is an integer, that is, v does not need to be a multiple of lcm(b) when performing Reduce.
Moreover, she wants to guarantee that the total length of b chosen over the operations does not exceed 106. Fine a possible operation sequence for her. You don't need to minimize anything.
来吧,让我们构建一个连弱者都不会被遗忘的世界!
——琪露诺·赛娅,《双重契约》
神明丸拥有一把可以将物体变大或变小的木槌。她正在对一个序列 a 和一个初始值为 1 的数 v 进行测试。她的目标是通过至多 105 次操作,使得 v=i=jgcdai⋅aj(此处 i=jgcdai⋅aj 表示序列 a 中所有互异下标元素两两乘积的最大公约数)。
每次操作中,她从 a 中选取一个子序列 b,并执行以下两种操作之一:
- 放大:v=v⋅lcm(b)
- 缩小:v=lcm(b)v
注意:她无需保证 v 始终为整数,即在执行“缩小”操作时,v 不必是 lcm(b) 的倍数。
此外,她希望确保所有操作中所选子序列 b 的总长度(即所有 ∣b∣ 之和)不超过 106。请为她构造一个可行的操作序列。你无需最小化任何量。
输入格式
The first line contains a single integer n (2≤n≤105) — the size of sequence a.
The second line contains n integers a1,a2,⋯,an (1≤ai≤106) — the sequence a.
It can be shown that the answer exists.
第一行包含一个整数 n(2≤n≤105)——序列 a 的长度。
第二行包含 n 个整数 a1,a2,⋯,an(1≤ai≤106)——序列 a。
可以证明答案一定存在。
输出格式
The first line contains a non-negative integer k (0≤k≤105) — the number of operations.
The following k lines contains several integers. For each line, the first two integers f (f∈0,1) and p (1≤p≤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 i1,i2,…,ip (1≤i1<i2<…<ip≤n) represents the indexes of the subsequence. Formally, bj=aij.
第一行包含一个非负整数 k(0≤k≤105)—— 表示操作次数。
接下来的 k 行每行包含若干个整数。对于每一行,前两个整数 f(f∈{0,1})和 p(1≤p≤n)分别表示所选操作(0 表示“放大”,1 表示“缩小”)以及子序列 b 的长度;该行其余 p 个整数 i1,i2,…,ip(1≤i1<i2<…<ip≤n)表示子序列的下标。形式化地,有 bj=aij。
输入输出样例
输入#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:
i=jgcdai⋅aj=gcd60,90,150=30.
Perform v=v⋅lcma1,a2,a3=30.
Test case 2:
i=jgcdai⋅aj=8.
Perform v=v⋅lcma4=16.
Perform v=lcma1v=8.
测试用例 1:
i=jgcdai⋅aj=gcd60,90,150=30。
执行 v=v⋅lcma1,a2,a3=30。
测试用例 2:
i=jgcdai⋅aj=8。
执行 v=v⋅lcma4=16。
执行 v=lcma1v=8。
输入解题思路,AI测评打分。不知道怎么写?