2639All become cycles

2639   All become cycles

题目描述

Jane likes cycles. One day she gets a tree. Jane plans to make some changes on it. She hopes that after adding some edges, its each vertex will only belong to exactly one cycle. Besides, she also hopes that there won’t exist self-loops. Because she thinks the self-loop is not a normal cycle. In order to prevent Jane wasting time on some impossible things, please tell her whether she can finish her plan or not in advance.

输入格式:

There are multiple cases.

For each case, the first line is an integer N (1<=N<=105), indicating Jane’s tree has N vertices. Then following N – 1 Lines. Each line contains two integers Ai,Bi (1<= Ai,Bi<=N), indicating there is an edge between Ai and Bi.

It’s guaranteed that the input data will form a tree.

输出格式:

For each case, output Possible if Jane can finish her plan, otherwise output Impossible.

输入样例 复制
7
1 2
1 3
2 4
2 5
3 6
3 7
10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
7 9
7 10
输出样例 复制
Impossible
Possible

说明

In the second case, one way is to add three edges: (5, 6), (4, 8), (9, 10). So that there are three cycles: {1, 2, 3, 5, 6}, {4, 8}, {7, 9, 10}.

1
1
通过提交
时空限制2000ms/32mb
题目来源数据结构实验与竞赛训练
评测方式在线评测
题目类型
难        度