QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#8186. 快速旅行染色

Statistics

给定一个包含 $7n$ 个顶点的完全无向图(其中 $n$ 是正整数)。你的任务是用 $n$ 种颜色为它的边染色,使得对于每一对顶点和每一种颜色,都存在一条由该颜色边组成的长度不超过 2 的路径连接这对顶点。更正式地说,对于每一对顶点 $u, v$ 和每一种颜色 $c$,以下两个选项中至少有一个成立:

  • 连接 $u$ 和 $v$ 的边颜色为 $c$;
  • 存在一个顶点 $w$,使得边 $(u, w)$ 和 $(w, v)$ 的颜色均为 $c$。

输入格式

输入仅包含一行,为一个正整数 $n$ ($7 \le 7n \le 1000$)。

输出格式

我们将颜色编号为 $1$ 到 $n$。令 $c_{i,j}$ 为 $0$(如果 $i = j$),否则为边 $(i, j)$ 的颜色(特别地,在这种情况下 $c_{i,j} = c_{j,i}$)。请输出 $7n$ 行,每行包含 $7n$ 个数字。

保证存在解。

样例

输入 1

1

输出 1

0 1 1 1 1 1 1
1 0 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 0 1 1 1
1 1 1 1 0 1 1
1 1 1 1 1 0 1
1 1 1 1 1 1 0

输入 2

2

输出 2

0 1 2 2 1 1 1 1 1 1 1 1 1 1
1 0 1 2 2 2 2 2 2 2 2 2 2 2
2 1 0 1 2 2 2 2 2 2 2 2 2 2
2 2 1 0 1 1 1 1 1 1 1 1 1 1
1 2 2 1 0 2 2 2 2 2 2 2 2 2
1 2 2 1 2 0 1 1 1 1 1 1 1 1
1 2 2 1 2 1 0 1 1 1 1 1 1 1
1 2 2 1 2 1 1 0 1 1 1 1 1 1
1 2 2 1 2 1 1 1 0 1 1 1 1 1
1 2 2 1 2 1 1 1 1 0 1 1 1 1
1 2 2 1 2 1 1 1 1 1 0 1 1 1
1 2 2 1 2 1 1 1 1 1 1 0 1 1
1 2 2 1 2 1 1 1 1 1 1 1 0 1
1 2 2 1 2 1 1 1 1 1 1 1 1 0

说明

第二个样例测试对应于以下染色方案:

这里是两种颜色的两个独立子图:

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.