| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 577 人关注过本帖
标题:Fishing Net
只看楼主 加入收藏
uranus18mtr
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2005-11-7
收藏
 问题点数:0 回复次数:0 
Fishing Net

给你个简单题吧
/////哪位高手,你击中我的软肋了,我到现在英语六级还没过,不过你的题目大概的意思了解,这几天一直考试,没时间细看,不过应该不是很烦的,下周五考完试耐心看看吧。谢谢你的题目,不错。特别是你的英语题目。


Fishing Net


--------------------------------------------------------------------------------


Time limit: 10 Seconds Memory limit: 32768K


--------------------------------------------------------------------------------


In a highly modernized fishing village, inhabitants there make a living on fishery. Their major tools, fishing nets, are produced and fixed by computer. After catching fishes each time, together with plenty of fishes, they will bring back the shabby fishing nets, which might be full of leaks. Then they have to inspect those nets. If there exist large leaks, they have to repair them before launching out again.

Obviously, the smaller the leaks in the fishing nets are, the more fishes they will catch. So after coming back, those fishermen will input the information of the fishing nets into the computer to check whether the nets have leaks.

The checking principle is very simple: The computer regards each fishing net as a simple graph constructed by nodes and edges. In the graph, if any circle whose length (the number of edges) is larger than 3 must has at least one chord, the computer will output "Perfect" indicating that the fishnet has no leaks. Otherwise, "Imperfect" will be displayed and the computer will try to repair the net.

Note: A circle is a closed loop, which starts from one node, passes through other distinct nodes and back to the starting node. A chord is an edge, which connects two different nodes on the circle, but it does not belong to the set of edges on the circle.

Input

The input file contains several test cases representing different fishing nets. The last test case in the input file is followed by a line containing 0 0.

The first line of each test case contains two integers, n and m, indicating the number of nodes and edges on the net respectively, 1 <= n <= 1000. It is followed by m lines accounting for the details of the edges. Each line consists of two integers xi and yi, indicating there is an edge between node xi and node yi.


Output

For each test case, display its checking results. The word "Imperfect" suggests that the corresponding fishing net is leaking, while the word "Perfect" stands for a fishing net in good condition.

Follow the output for each net with a blank line.


Sample Input

4 4
1 2
2 3
3 4
4 1
3 3
1 2
2 3
3 1
0 0


Output for the Sample Input

Imperfect

Perfect

搜索更多相关主题的帖子: Fishing Net 
2005-11-19 22:24
快速回复:Fishing Net
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026612 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved