-->
当前位置:首页 > 题库

PROGRAMMING:Magicpig escape

Luz5年前 (2021-05-10)题库388
There's a big room in the pyramid called room of no return. Unfortunately, magicpig is trapped in this room now. There are some hooks on the floor of the room. On the wall of the room were some ancient Egyptian words: "if you want to escape here, you have to connect all these hooks with ropes, and then a secret door will open, and you will be free. If you can't, you'll be stuck here forever. ". Fortunately, magicpig has a rope of length L, he can cut it into sections, and each section can be connected with two hooks. If he can use this rope to connect all the hooks, and the connected rope can not appear loop, he can successfully escape! Kinfkong wants to know if he can escape.
###Input format:
The input contains one or more datasets. In the first line of each input dataset, there are two integers n and l, where n is the number of hooks and l is the length of the rope. The next n rows contain a series of coordinates of the hook. Each coordinate is a pair of non negative integers, and each integer is less than 32768. Each pair is separated by a space (2 < = n < = 100, l < = 32767). Zero number of hooks indicates the end of input.
###Output format:
For each dataset, if magicpig can escape, print a string "success!", Otherwise, print "poor magicpig!"
###Input example:
```in
2 1
0 0
1 1
2 2
0 0
1 1
0
```
###Output example:
```out
Poor magicpig!
Success!
```







answer:If there is no answer, please comment