P27446 [AtCoder] Welcome Newcomer Sequence - Hard
NOI
题目描述

Problem Description

Score: $ 1000 $ points

PAKEN, a new member of the programming club, received a sequence $P = \{ P_1, P_2, P_3, ..., P_N \}$ of length $ N $ from E869120. Initially, all elements of $ P $ are $ 0 $.

PAKEN wants to make the sequence $ P $ identical to the sequence $A = \{ A_1, A_2, A_3, ..., A_N \}$ by performing the following operations in any order, up to a total of $ 550,000 $ times.

  • Operation 1: Choose an integer $ x $ between $ 1 $ and $ N $, and change $ P_x $ to $ 1 $.
  • Operation 2: Choose integers $ y $ and $ z $ between $ 1 $ and $ N $, and add the value of $ P_z $ to $ P_y $. Note that $ y = z $ is allowed. Also, the value of $ P_y $ must not exceed $ 10^{18} $.

Since PAKEN is still young, he doesn't know what sequence of operations to perform. To help him, you must show an example of the sequence of operations.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $ A_3 $ ... $ A_N $

Output Format

The output should be given from the standard output in the following format:

$ Q $ ($ information of the 1st operation $) ($ information of the 2nd operation $) ($ information of the 3rd operation $) ... ($ information of the Qth operation $)

First, you must output the number of operations $ Q $. $ Q $ must be an integer between $ 0 $ and $ 550,000 $. The next $ Q $ lines should contain the information of each operation as follows:

(☆) For Operation 1

$ 1 $ $ x $

This means to change $ P_x $ to $ 1 $.

(★) For Operation 2

$ 2 $ $ y $ $ z $

This means to add the value of $ P_z $ to $ P_y $.

Sample Input and Output

Sample Input #1

2
1 4

Sample Output #1

4
1 1
1 2
2 2 2
2 2 2

Sample Input #2

3
1 3 5

Sample Output #2

8
1 1
2 1 1
2 3 1
1 1
2 1 2
2 2 1
2 3 1
1 1

Notes/Hints

Constraints

  • $ N $ is an integer between $ 2 $ and $ 200,000 $.
  • $ A_1 = 1 $.
  • $ A_i $ ($1 \leq i \leq N$) is an integer between $ 1 $ and $ 2^{30} - 1 $.

Subtasks

Subtask 1 \[ $ 60 $ points \]

  • $ N = 2 $.

Subtask 2 \[ $ 140 $ points \]

  • $N \leq 8,000$.

Subtask 3 \[ $ 80 $ points \]

  • $N \leq 16,000$.

Subtask 4 \[ $ 230 $ points \]

  • $N \leq 25,000$.

Subtask 5 \[ $ 270 $ points \]

  • $N \leq 160,000$.

Subtask 6 \[ $ 220 $ points \]

No additional constraints.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1 4
样例输出
4 1 1 1 2 2 2 2 2 2 2