编程介的小学生 2019-06-20 20:32 采纳率: 20.5%
浏览 131

结构体的构造的一个问题,怎么使用C语言的程序的设计的解决的方式怎么来实现的呢

Problem Description
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.

Input
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).

Output
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.

Sample Input
7 6 3
6 6 3

Sample Output
0 1
0 2
0 3
1 4
2 5
3 6
Invalid

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
    • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
    • ¥30 3天&7天&&15天&销量如何统计同一行
    • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码