#abc276b. B - Adjacency List
B - Adjacency List
Score : points
问题描述
有 座编号为 的城市,以及 条连接这些城市的道路。
第 条道路 连接城市 和城市 。
按以下方式打印出 行内容:
- 让 表示与城市 直接相连的城市数量,这些城市依次为城市 、、城市 ,并按照 升序 排列。
- 第 行 应包含 个整数,按照 的顺序排列,并用空格隔开。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are cities numbered , and roads connecting cities.
The -th road connects city and city .
Print lines as follows.
- Let be the number of cities directly connected to city , and those cities be city , , city , in ascending order.
- The -th line should contain integers in this order, separated by spaces.
Constraints
- if .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines as specified in the Problem Statement.
Sample Input 1
6 6
3 6
1 3
5 6
2 5
1 2
1 6
Sample Output 1
3 2 3 6
2 1 5
2 1 6
0
2 2 6
3 1 3 5
The cities directly connected to city are city , city , and city . Thus, we have , so you should print in the first line in this order, separated by spaces.
Note that must be in ascending order. For instance, it is unacceptable to print in the first line in this order.
Sample Input 2
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
Sample Output 2
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4
update @ 2024/3/10 11:36:45