当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3701:Country X

题目描述
Country X is a country with special structure.

1. It consists of N cities. The indices of the cities are from 0 to N - 1.
2. There are exact M roads between cities. A road is a bidirectional path that connects two different cities. There is at most one road between any two cities. There are no roads connect a city to itself.
3. You can travel from each city to any other cities using these roads. In other words, all the cities are in one connect component.
4. There is exact one special city called centre city X. When X is removed (the roads connect with X are also removed), the cities are partitioned into K parts. There are no roads between any two parts. For each part, you can travel from each city to any other cities in this part (each of the K parts is a connect component).
5. Most important of all, each of the K parts is identical to each other.

Now given N, M, and K, you are asked to construct a valid structure for Country X.
输入解释
There are no more than 100 cases. For each case, there is only one line giving 3 integers N M K (2 <= N <= 500, 0 <= M <= 10000, 1 <= K <= N).
输出解释
If there isn't a valid structure, output "Invalid". Otherwise, you need to output all the M roads in M lines. A road is a pair "A B" meaning there is a road between city A and city B (0 <= A, B < N, A != B). If there are more than one valid structure, you should output the lexicographically smallest list of roads. A list of roads R [R1, R2, ... RM] is lexicographically smaller than Q [Q1, Q2, ... QM] if R contains a smaller road at the first index where they differ. A road "A B" is smaller than the road "C D" if A < C or A = C and B < D.
输入样例
7 6 3
6 6 3
输出样例
0 1
0 2
0 3
1 4
2 5
3 6
Invalid
来自杭电HDUOJ的附加信息
Author hhanger@ZJU
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3701

最后修改于 2020-10-25T23:06:12+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)