QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#3539. 数字重排

الإحصائيات

你需要根据给定的一组数字来组成若干个数字。每个数字都有一个上限。给定集合中的每个数字必须恰好使用一次。如果集合中不包含某个数字,则不允许使用它。

输入格式

第一行包含一个整数 $t$ —— 测试用例的数量。 接下来的 $t$ 行,每行包含一个字符串 $s$ —— 给定的一组数字,一个整数 $n$ —— 需要组成的数字的数量,以及 $n$ 个整数 $a_i$ —— 这些数字的上限。所有 $a_i$ 的数字均按从最高位到最低位非递增的顺序给出。给定集合中的数字和 $a_i$ 均不包含数字 $0$。

$1 \le t \le 1000$ $1 \le |s| \le 500$ $1 \le n \le 50$ $1 \le a_i \le 10^9$

输出格式

你需要输出 $t$ 行,每行包含符合上述条件的 $n$ 个数字。如果不存在解,则输出 "-1"。如果存在多个解,你可以输出其中任意一个。

样例

输入 1

3
1234 2 21 43
12534 2 21 43
42 1 42

输出 1

14 23
-1
42

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.