QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#10138. 信号

Estadísticas

布加勒斯特国际计算机学院拥有一个由 $N$ 台计算机组成的环形网络。计算机 $i$(对于 $1 \le i < N$)通过链路 $i$ 与计算机 $i+1$ 相连。计算机 $N$ 和 $1$ 也通过链路 $N$ 相连。

每台计算机都有一个包含 $K$ 位信息的安全密钥,表示为一个长度为 $K$ 的二进制字符串。每条链路 $i$ 也有一个安全阈值 $W_i$。通过该链路连接的两台计算机,仅当它们的密钥在恰好 $W_i$ 个位置上不同时,才能进行通信。

系统管理员丢失了安全密钥,需要你帮助生成新的密钥,使得每一条链路都能进行通信。

输入格式

输入的第一行包含一个整数 $T$,表示需要解决的测试用例数量。接下来是 $T$ 个测试用例的描述。

每个测试用例的第一行包含两个空格分隔的整数 $N, K$。每个测试用例的第二行包含 $N$ 个空格分隔的整数 $W_1, W_2, \dots, W_N$。

输出格式

输出 $T$ 个测试用例的答案。每个测试用例的答案描述如下:

如果该测试用例无解,则输出的第一行(也是唯一一行)必须包含字符串 NO。否则,输出的第一行必须包含字符串 YES,接下来的 $N$ 行(即第 $2$ 行到第 $N+1$ 行)必须包含一个有效的安全密钥列表。每台计算机 $i$ 的安全密钥必须作为二进制字符串打印在第 $(i+1)$ 行,且中间不包含任何空格。

数据范围

  • $1 \le T \le 100\,000$
  • $2 \le N$
  • $2 \le NK \le 5\,000\,000$
  • $0 \le W_i \le K$
  • 保证所有测试用例的 $NK$ 之和不超过 $5\,000\,000$。
  • 如果你正确判断了是否存在解,但输出的密钥不正确(但格式正确),你将获得该子任务 50% 的分数。
  • 令 $W_{\max}$ 为所有 $W_i$ 中的最大值。

子任务

# 分值 数据范围
1 5 $T, N, K \le 5$
2 2 $K = 1$
3 8 $K = 2$
4 32 $2W_{\max} \le K$
5 24 $N \le 50\,000, K \le 20$
6 29 无额外限制。

样例

样例输入 1

3
5 3
2 1 3 0 2
10 6
3 2 1 4 3 2 1 3 2 1
2 3
2 1

样例输出 1

YES
000
110
010
101
101
YES
000000
111000
111110
111111
000011
111011
011111
111111
000111
000001
NO

说明

对于第一个测试用例,安全密钥 000110 在 2 个位置上不同,110010 在 1 个位置上不同,010101 在 3 个位置上不同,101101 在 0 个位置上不同,101000 在 2 个位置上不同,满足所有五个安全阈值。

对于最后一个测试用例,不存在一种选择安全密钥的方式使得所有条件都得到满足。因此,输出 NO

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.