CF1583F.Defender of Childhood Dreams
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Even if you just leave them be, they will fall to pieces all by themselves. So, someone has to protect them, right?
You find yourself playing with Teucer again in the city of Liyue. As you take the eccentric little kid around, you notice something interesting about the structure of the city.
Liyue can be represented as a directed graph containing n nodes. Nodes are labeled from 1 to n. There is a directed edge from node a to node b if and only if a<b.
A path between nodes a and b is defined as a sequence of edges such that you can start at a, travel along all of these edges in the corresponding direction, and end at b. The length of a path is defined by the number of edges. A rainbow path of length x is defined as a path in the graph such that there exists at least 2 distinct colors among the set of x edges.
Teucer's favorite number is k. You are curious about the following scenario: If you were to label each edge with a color, what is the minimum number of colors needed to ensure that all paths of length k or longer are rainbow paths?
Teucer wants to surprise his older brother with a map of Liyue. He also wants to know a valid coloring of edges that uses the minimum number of colors. Please help him with this task!
即使你放任不管,它们也会自行分崩离析。因此,总得有人来守护它们,对吧?
你又一次在璃月城中与特瓦林玩耍。当你带着这位古怪的小家伙四处逛游时,你注意到了这座城市的结构中一些有趣的现象。
璃月可以被表示为一个包含 n 个节点的有向图。节点编号从 1 到 n。当且仅当 a<b 时,图中存在一条从节点 a 指向节点 b 的有向边。
节点 a 与节点 b 之间的一条路径定义为:一组边构成的序列,使得你可以从 a 出发,沿这些边的指定方向依次行进,最终到达 b。路径的长度定义为该路径所含边的数量。长度为 x 的“彩虹路径”(rainbow path)是指图中这样一条路径:其包含的 x 条边中,至少存在两种不同的颜色。
特瓦林最钟爱的数字是 k。你对如下问题感到好奇:若给每条边染上一种颜色,那么为保证所有长度不小于 k 的路径均为彩虹路径,所需的最少颜色数是多少?
特瓦林想用一张璃月地图给他的哥哥一个惊喜。他还想知道一种使用最少颜色数的有效边染色方案。请帮他完成这项任务!
输入格式
The only line of input contains two integers n and k (2≤k<n≤1000).
输入仅有一行,包含两个整数 n 和 k(2≤k<n≤1000)。
输出格式
On the first line, output c, the minimum colors you need to satisfy the above requirements.
On the second line, print a valid edge coloring as an array of 2n(n−1) integers ranging from 1 to c. Exactly c distinct colors should exist in the construction. Print the edges in increasing order by the start node first, then by the second node.
For example, if n=4, the edge colors will correspond to this order of edges: (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)
第一行输出 c,即满足上述要求所需的最少颜色数。
第二行输出一个合法的边着色方案,表示为一个包含 2n(n−1) 个整数的数组,每个整数取值范围为 1 到 c。该构造中必须恰好出现 c 种互不相同的颜色。边的输出顺序需按起始节点升序排列,起始节点相同时再按终点节点升序排列。
例如,当 n=4 时,边的颜色按如下边的顺序给出:(1, 2),(1, 3),(1, 4),(2, 3),(2, 4),(3, 4)
输入输出样例
输入#1
5 3
输出#1
2 1 2 2 2 2 2 2 1 1 1
输入#2
5 2
输出#2
3 3 2 2 1 2 2 1 3 1 1
输入#3
8 7
输出#3
2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
输入#4
3 2
输出#4
2 1 2 2
说明/提示
The corresponding construction for the first test case looks like this:

It is impossible to satisfy the constraints with less than 2 colors.
The corresponding construction for the second test case looks like this:

One can show there exists no construction using less than 3 colors.
第一个测试用例对应的构造如下所示:

无法用少于 2 种颜色满足约束条件。
第二个测试用例对应的构造如下所示:

可以证明,不存在使用少于 3 种颜色的构造方案。
输入解题思路,AI测评打分。不知道怎么写?