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

建议使用的浏览器:

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

3222:Edge Pairing

Special Judge 特殊评判
题目描述

Given a simple connected undirected graph with n vertices and m edges, where m is even, your task is to find a pairing of the edges such that each pair of edges shares a vertex.

输入解释

The input contains exactly one test cases. On the first line of the test case there are two integers n and m (3 ≤ n ≤ 20,000, 2 ≤ m ≤ 100,000, m is even) which indicate the size of the graph. Next come m lines each with a pair of integers a and b representing an edge (a, b). The vertices are numbered 1 through n.

输出解释

If a pairing exists, output it in m2 lines. Each line contains three integers a, b and c in this order, indicating that the edges (a, b) and (b, c) are paired together. If no pairing exists, just output “NO” and nothing else.

输入样例
7 10
1 2
1 3
2 4
3 4
4 5
4 6
5 7
6 7
2 5
3 6
输出样例
1 2 4
1 3 4
4 5 2
4 6 3
5 7 6
提示

Illustration of the sample test case:


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3222

最后修改于 2020-10-29T06:56:10+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 131072