luogu#P7025. [NWRRC2017] Grand Test
[NWRRC2017] Grand Test
题目描述
Jeremy, Richard and James like to test cars. It is always hard for them to decide where they should do it. Usually car test looks like this. They choose a country and examine its cities and two-way roads that connect them. To perform a test, they need to choose two different cities and , such that there exist three routes between them. Moreover, each city except and should be visited by at most one route, and none of the roads may be used twice.
Then each of them takes a car in city , drives along one of those routes and tries to get to city faster than others.
You are given a description of multiple countries. For each country you should decide if it is possible to choose two cities and three routes between them in a way described above.
输入格式
The first line of the input contains a single integer -- number of countries . It is followed by country descriptions.
The first line of each country description contains two integers and -- the number of its cities and roads . The following lines contain two integer numbers each: and -- the cities at the ends of the road . All roads are two-way. Each pair of cities is connected by at most one road.
Both the total number of cities and roads in all countries does not exceed .
输出格式
Output the answer for each country in the order they are given in the input.
If it is not possible to test cars in this country, the answer is . Otherwise the first line of the answer should contain two integers and -- start and finish cities. The next three lines should contain three distinct routes. Each route is described by an integer -- the number of cities it visits, and numbers -- the cities, where , and there is a road between cities and for all .
题目大意
题目描述
给定一张 个节点 条边的无向图,请在图中找出两个点 和 ,使得这两点间至少存在三条不相交的路径。
输入格式
输入的第一行包数据组数 。对于每组数据,第一行为两个整数 和 。接下来 行每行包含两个整数 和 ,表示节点 和 之间有一条边。每对节点至多被一条边连接。保证 及 不超过 。
输出格式
对于每组数据,若不存在,则输出-1
。若存在,则第一行输出 和 。接下来三行输出三条路径。每行先输出路径路径包含的点数,然后依次输出由 到 的路径上各点。
2
6 6
3 6
3 4
1 4
1 2
1 3
2 3
3 1
1 2
1 3
3 1 2 3
2 1 3
3 1 4 3
-1
提示
Time limit: 3 s, Memory limit: 512 MB.