QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#2595. 有趣的子段

Statistiques

如果一个数组的子段(连续子数组)中所有元素的和能被 3 整除,则称该子段是“有趣的”。

给定两个整数 $n$ 和 $k$。你的目标是构造一个长度为 $n$ 的字典序最小的数组,使得该数组仅由整数 0、1 和 2 组成,且恰好包含 $k$ 个不同的有趣子段。

如果两个长度为 $n$ 的数组 $a$ 和 $b$ 满足存在 $1 \le i \le n$,使得对于所有 $j < i$ 都有 $a_j = b_j$ 且 $a_i < b_i$,则称数组 $a$ 的字典序小于数组 $b$。如果两个子段包含的元素位置集合不同,则称这两个子段是不同的。

输入格式

输入仅一行,包含两个整数 $n$ 和 $k$ ($1 \le n \le 10^6$, $0 \le k \le 10^{18}$)。

输出格式

如果不存在这样的数组,输出 -1。否则,输出满足条件的长度为 $n$ 的字典序最小的数组。

样例

样例输入 1

5 3

样例输出 1

0 1 0 1 0

样例输入 2

5 5

样例输出 2

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.