johnie
In
Task
Being given the number of cities from the
Input Data
Line one of input file johnie.in describes two positive integers separated by a space, N, representing the number of cities and M, representing the number of alleyways. Each of the following M lines contains two distinct positive integers, i j (between 1 and N) with the meaning that there is a path from city i to city j.
Output Data
Output file johnie.out will contain on line one a positive integer min representing the minimum number of walk stages. The following min lines represent the trips Johnie travels every day in each stage, one trip per line. The first number off the line describing a trip is the number of cities traveled in said trip, and the following numbers representing the cities traveled, in the order they are traveled. Numbers written on the same line are separated by a space.
Restrictions and Mentions
•
1 <= N <= 50000
•
1 <= M <= 100000
•There can be more than one alleyway between two cities.
•An alleyway is two-directional.
•There are no alleyways beginning and ending in the same city.
Example
johnie.in |
johnie.out |
7 7 |
2 |
Time limit: 0.5 seconds/test
Daniel Pasaila
"Al. I Cuza" University, Iaşi - IT Department
danielpasaila@yahoo.com