#P7282. [COCI 2020/2021 #4] Hop

[COCI 2020/2021 #4] Hop

Description

There are nn lily pads, numbered from 11 to nn in order. On the ii-th pad there is an integer xix_i, and the sequence (xi)1in(x_i)_{1 \le i \le n} is strictly increasing.

Three frogs arrive.

Every pair of lily pads (a,b)(a,b) with a<ba \lt b must be assigned to exactly one of frogs 1,2,1,2, or 33.

If a pair (i,j)(i,j) is assigned to a frog and xjx_j is divisible by xix_i (j>ij \gt i), then that frog can jump from pad ii to pad jj.

Find an assignment such that no frog can make more than 33 consecutive jumps.

Input Format

The first line contains a positive integer nn, the number of lily pads.

The second line contains nn positive integers xix_i, the integers on the lily pads.

Output Format

Output n1n-1 lines. On line ii, output ii integers, where the jj-th integer on that line indicates which frog the pair (j,i+1)(j,i+1) is assigned to.

8
3 4 6 9 12 18 36 72
1
2 3
1 2 3
1 2 3 1
2 3 1 2 3
1 2 3 1 2 3
1 2 3 1 2 3 1
2
10 101
1

Hint

Explanation of Sample 1

Frogs 1,2,31,2,3 are represented by blue, green, and red, respectively.

The blue frog can jump from x1=3x_1=3 to x4=9x_4=9, then to x7=36x_7=36, and then to x8=72x_8=72. This frog can make only 33 consecutive jumps.

The green frog can jump from x2=4x_2=4 to x5=12x_5=12, and then to x7=36x_7=36. This frog can make only 22 consecutive jumps.

The red frog cannot jump from x2=4x_2=4 to x3=6x_3=6, because 66 is not divisible by 44.

Constraints

This problem uses bundled evaluation.

Subtask Points Constraints and notes
11 1010 n30n \le 30
22 100100 None

For 100%100\% of the testdata, 1n10001 \le n \le 1000, 1xi10181 \le x_i \le 10^{18}.

Scoring

In your output, if one frog can make kk consecutive jumps with k>3k \gt 3, and no frog can make k+1k+1 consecutive jumps, then the score for that test point is f(k)xf(k)·x points, where:

$$f(k)=\dfrac{1}{10}· \begin{cases} 11-k & (4 \le k \le 5) \cr 8-\lfloor {\dfrac{k}{2}} \rfloor & (6 \le k \le 11) \cr 1 & (12 \le k \le 19) \cr 0 & (k \ge 20) \cr \end{cases}$$

Here, xx is the total score of the corresponding subtask. The score of each subtask equals the minimum score among all test points in that subtask.

Because the scoring of this problem is special, a non-official self-written Special Judge is enabled. You can also download it from the attachments. Everyone is welcome to hack (you may send a private message or post directly).

Notes

The points of this problem follow the original COCI setting, with a full score of 110110.

Translated from COCI2020-2021 CONTEST #4 T3 Hop.

Translated by ChatGPT 5