QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11671. Linie autobusowe

Statistics

在 Bajtocja 有 $n$ 个城市,它们由双向道路连接,道路旁分布着许多村庄。国王 Bajtazar 决定建立一张服务城市与村庄的公交线路网络。每条线路可以在任意城市开始和结束,并且可以经过任意城市。线路路径中城市允许重复出现。但是,任何一条线路都不能多次经过同一条道路。

为了让所有居民都能出行,同时尽量降低建设成本,国王 Bajtazar 规定:每条道路恰好由一条公交线路经过,并且公交线路的条数要最少

任务

编写程序:

  • 读入道路网络的描述;
  • 设计满足要求的公交线路网络;
  • 输出结果。

输入格式

第一行包含两个整数 $n$ 和 $m$,以单个空格分隔,$2 \le n \le 10,000$,$n-1 \le m \le 200,000$;其中 $n$ 为城市数量,$m$ 为道路数量。城市编号为 $1$ 到 $n$。接下来 $m$ 行描述道路网络。每行包含两个整数 $a$ 和 $b$,以单个空格分隔,$1 \le a < b \le n$,表示编号为 $a$ 与 $b$ 的城市之间有一条道路。每条道路在输入中恰好出现一次。你可以假设任意两座城市之间最多只有一条直接道路(尽管可能存在多条不同路径连接两座城市),并且任意两座城市之间都可以互相到达。

输出格式

第一行输出整数 $c$,表示最少需要的公交线路数量。接下来 $c$ 行输出各条线路的描述:第 $i$ 条线路应输出一个整数 $l_i$,表示该线路路径上的城市数量,随后输出 $l_i$ 个城市编号,按线路行驶顺序给出。每行中的数字应以单个空格分隔。如果一条线路的起点和终点是同一座城市,则该城市编号应同时出现在路径描述的开头与结尾。

样例数据

输入

4 6
1 2
2 4
2 3
1 3
3 4
1 4
problem_11671_1.jpg

输出

2
6 2 1 3 2 4 3
2 1 4

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.