QOJ.ac

QOJ

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

#11802. 图的度量

Statistiques

Andrew 拥有一个包含 $n$ 个顶点的简单(无自环,无重边)无向图 ($1 \le n \le 20$)。他重复进行以下测量 $k$ 次:对于图中的每一条边,独立地将其染成黑色或白色(每种颜色概率均为 50%)。然后,他统计与每个顶点相邻的黑色边的数量,并将这 $n$ 个数字告诉你。

你的目标是根据这 $k \cdot n$ 个数字还原出原始图。

输入格式

第一行包含两个整数 $n$ 和 $k$($1 \le n \le 20$,除样例输入外,所有情况均满足 $k = 800 \cdot n^2$)。接下来的 $k$ 行,每行包含 $n$ 个整数,表示在对应测量中与每个顶点相邻的黑色边的数量。顶点编号为 $1$ 到 $n$,每行中的数值按顶点编号顺序给出。

输出格式

第一行输出一个整数 $m$ —— 你认为用于生成输入的图中边的数量。接下来的 $m$ 行描述这些边。每条边应由它连接的两个顶点编号描述。顶点编号为 $1$ 到 $n$,图中不能有连接顶点自身的边,且任意一对顶点之间最多只能有一条边。

在样例中,任何合法的图都会被接受,即使它与输入不一致(例如,包含 0 条边的图也会被接受)。除样例外,所有情况下,只有实际用于生成输入的图才会被接受。

边的输出顺序以及每条边内两个顶点的输出顺序不限,你可以使用任意顺序。

样例

输入 1

3 2
1 2 1
1 1 0

输出 1

2
1 2
2 3

说明

注意,除样例外,所有测试用例都有大量的测量数据 —— 更准确地说,$k = 800 \cdot n^2$。

在上述样例输入和输出中,第一次测量时两条边都被染成了黑色,第二次测量时只有第一条边被染成了黑色。

本题共有 33 个非样例测试用例。

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.