#P8248. Beautiful Sequence Construction

    ID: 21427 Type: Default 1000ms 256MiB

Beautiful Sequence Construction

Beautiful Sequence Construction

You are given an integer \( n \). Your task is to construct an array \( a \) of length \( n \) (with indices starting at 1) where each element is one of \( \{1,2,3,4\} \). The array must satisfy the following condition:

  • For each index \( i \) (1-based), for every \( 1 \leq len \leq \lfloor \frac{i}{2} \rfloor \), the consecutive subarray \( a_{i-len+1\dots i} \) must not be identical to the immediately preceding subarray \( a_{i-2\times len+1\dots i-len} \).

In other words, no adjacent blocks of the same length (and consecutively placed) in the sequence should be identical. If multiple answers exist, you may output any one of them.

Note: The notation \( \lfloor x \rfloor \) denotes the floor of \( x \) (i.e. rounding down to the nearest integer).

inputFormat

The input consists of a single integer \( n \) on one line, representing the length of the sequence to be constructed.

outputFormat

Output a beautiful sequence of \( n \) numbers chosen from \( \{1,2,3,4\} \) such that the sequence satisfies the condition described above. The numbers should be printed consecutively separated by a space.

sample

1
1