시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 17 | 6 | 5 | 33.333% |
A subsegment (contiguous subarray) of an array is interesting if the sum of values on this subsegment is divisible by $3$.
You are given two integers $n$ and $k$. Your goal is to construct the lexicographically minimal array of length $n$ such that it consists only of integers $0$, $1$, and $2$, and has exactly $k$ distinct interesting subsegments.
Array $a$ of length $n$ is lexicographically smaller than array $b$ of the same length if there is $1 \le i \le n$ such that $a_j = b_j$ for $j < i$ and $a_i < b_i$. Two subsegments are distinct if some element of the array belongs to one subsegment but not to the other.
The only line of input contains two integers $n$ and $k$ ($1 \le n \le 10^6$, $0 \le k \le 10^{18}$).
Output -1
if there is no such array. Otherwise, output the lexicographically smallest array of size $n$ which satisfies the constraints.
5 3
0 1 0 1 0
5 5
-1