Sei sulla pagina 1di 2

E CONTINUOUS HAND DRAWING

Input File: handdraw.in

Hiro Takarobi wants to teach his experimental robot hand to draw figures with a kind of “Logo turtle”
mechanism. The robot hand can put a writing head on a paper and move it drawing edges between points
that Hiro defines. In a first stage of the robot hand training, Hiro wants to teach it to draw only figures that
can be drawn in a continuous way: putting the head on the paper, drawing edges between points, and lifting
the head from the paper. Each edge should be drawn only once.

You are concerned with helping Hiro with the drawing step, but only with telling if a figure can be drawn
continuously and, if this is the case, giving an order for the end points of the edges to determine how the
drawing could be produced (be aware that there could be several ways to accomplish it).

For instance, consider the following pictures (the actual position of the end points is irrelevant for your
problem):
5
4 3
4 3

1 2 1 2

The left one can be drawn continuously in the order 4, 2, 5, 1, 3, 4. The other one cannot be drawn without
lifting the writing head at least once.

INPUT

A series of figure descriptions, each one of the form:


xxxxx
N
1 i11 i12 … i1,m1
2 i21 i22 … i2,m2
...
N iN1 iN2 … iN,mN

where xxxxx is an identifier for the figure (a string) and N>0 is the number of points that determine edges.
Points are denoted with numbers in 1..N. For 1≤p≤N, each line of the form
p ip1 ip2 … ip,mp
establishes edges between p and each one of the ipq's. These edges must be drawn, but the direction of the
drawing is not fixed. The same edge could be referenced in line q with a corresponding iqp, but it may be
omitted too.

Following the last case there is a line with the string:


***

OUTPUT

For each analyzed figure, in the same order that problems were presented, two output lines. If the figure can
be drawn continuously (xxxxx is the figure identifier, E-1 is the number of drawn edges):
xxxxx: Yes
p1 p2 … pE

to mean that drawing the edges (p1, p2),(p2, p3),…,(pE-1,pE) the figure is correctly drawn. In other
case, the output lines should be:
xxxxx: No
0

E - Continuous Hand Drawing 1/2


SAMPLE INPUT
Star
5
1 3 5
2 4 5
3 4
4
5
XBox
4
1 2 3 4
2 3 4
3 4
4
***

OUTPUT FOR THE SAMPLE INPUT


Star: Yes
4 2 5 1 3 4
XBox: No
0

E - Continuous Hand Drawing 2/2

Potrebbero piacerti anche