CF822F.Madness

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The second semester starts at the University of Pavlopolis. After vacation in Vičkopolis Noora needs to return to Pavlopolis and continue her study.

Sometimes (or quite often) there are teachers who do not like you. Incidentally Noora also has one such teacher. His name is Yury Dmitrievich and he teaches graph theory. Yury Dmitrievich doesn't like Noora, so he always gives the girl the most difficult tasks. So it happened this time.

The teacher gives Noora a tree with nn vertices. Vertices are numbered with integers from 11 to nn . The length of all the edges of this tree is 11 . Noora chooses a set of simple paths that pairwise don't intersect in edges. However each vertex should belong to at least one of the selected path.

For each of the selected paths, the following is done:

  1. We choose exactly one edge (u,v)(u,v) that belongs to the path.
  2. On the selected edge (u,v)(u,v) there is a point at some selected distance xx from the vertex uu and at distance 1x1-x from vertex vv . But the distance xx chosen by Noora arbitrarily, i. e. it can be different for different edges.
  3. One of the vertices uu or vv is selected. The point will start moving to the selected vertex.

Let us explain how the point moves by example. Suppose that the path consists of two edges (v1,v2)(v_{1},v_{2}) and (v2,v3)(v_{2},v_{3}) , the point initially stands on the edge (v1,v2)(v_{1},v_{2}) and begins its movement to the vertex v1v_{1} . Then the point will reach v1v_{1} , then "turn around", because the end of the path was reached, further it will move in another direction to vertex v2v_{2} , then to vertex v3v_{3} , then "turn around" again, then move to v2v_{2} and so on. The speed of the points is 11 edge per second. For example, for 0.50.5 second the point moves to the length of the half of an edge.

A stopwatch is placed at each vertex of the tree. The time that the stopwatches indicate at start time is 00 seconds. Then at the starting moment of time, all points simultaneously start moving from the selected positions to selected directions along the selected paths, and stopwatches are simultaneously started. When one of the points reaches the vertex vv , the stopwatch at the vertex vv is automatically reset, i.e. it starts counting the time from zero.

Denote by resvres_{v} the maximal time that the stopwatch at the vertex vv will show if the point movement continues infinitely. Noora is asked to select paths and points on them so that res1res_{1} is as minimal as possible. If there are several solutions to do this, it is necessary to minimize res2res_{2} , then res3res_{3} , res4,...,resnres_{4},...,res_{n} .

Help Noora complete the teacher's task.

For the better understanding of the statement, see the explanation for the example.

输入格式

The first line contains single integer nn ( 2<=n<=1002<=n<=100 ) — number of vertices in the given tree.

Each of next n1n-1 lines contains two integers uu and vv ( 1<=u,v<=n,uv1<=u,v<=n,u≠v ) — vertices connected by an edge.

Guaranteed that input defines a valid tree.

输出格式

In the first line print single integer pathspaths — number of paths you want to choose.

In the next pathspaths lines print path's descriptions:

  1. Single integer lenlen — number of edges in the current path.
  2. lenlen integers — indices of the edges in the path. The edges are numbered from 11 to n1n-1 in order they are given in input.
  3. Two integers uu and vv — means that you put point on the edge between vertices uu and vv (obviously the edge should belong to the path) and a point will start moving to the vertex vv . Note that order of printing of the edge's ends is important. For example if you print "1 2" (without quotes), then point will start moving to vertex 22 ; but if you print "2 1" (without quotes), then point will start moving to vertex 11 .
  4. Single real number xx ( 0<=x<=10<=x<=1 ) — distance between point and vertex uu (the same vertex that you print first in the third paragraph).

Scoring

Judge system will generate array resres using the output data provided by the participant. Also system will generate array resOptimalresOptimal by the jury answer. Your answer will be accepted if only for each ii ( 1<=i<=n1<=i<=n ) the following is satisfied: .

输入输出样例

  • 输入#1

    3
    1 2
    2 3
    

    输出#1

    2
    1 1 1 2 0.6666666666
    1 2 2 3 0.6666666666
    

说明/提示

Consider an example.

In starting moment of time points are located as following:

The first path is highlighted in red, the second in blue, green circles represent chosen points, and brown numbers inside vertices — current time at stopwatch. Purple arrows represent direction in which points will move.

In 0.(3)0.(3) seconds points will be located in following way (before stopwatch reset):

After stopwatch reset:

In 1.01.0 second after the start of moving:

In 1.(3)1.(3) seconds after the start of moving (after stopwatch reset):

Finally, in 22 seconds after the start of moving points return to their initial positions.

This process will continue infinitely.

首页