a443: 10720 - Graph Construction
Tags :
Accepted rate : 31人/73人 ( 42% ) [非即時]

最近更新 : 2012-03-29 23:40


Graph is a collection of edges E and vertices V. Graph has a wide variety of applications in computer. There are different ways to represent graph in computer. It can be represented by adjacency matrix or by adjacency list. There are some other ways to represent graph. One of them is to write the degrees (the numbers of edges that a vertex has) of each vertex. If there aren vertices then n integers can represent that graph. In this problem we are talking about simple graph which does not have same endpoints for more than one edge, and also does not have edges with the same endpoint.

Any graph can be represented by n number of integers. But the reverse is not always true. If you are given n integers, you have to find out whether thisn numbers can represent the degrees of n vertices of a graph.



Each line will start with the number n (≤ 1000000). The next n integers will represent the degrees of n vertices of the graph. A 0 input for n will indicate end of input which should not be processed.
If the n integers can represent a graph then print “Possible”. Otherwise print “Not possible”. Output for each test case should be on separate line.
Sample Input #1
4 3 3 3 3
6 2 4 5 5 2 1
5 3 2 3 2 1
Sample Output #1
Not possible
Not possible
記憶體限制: 512 MB
公開 測資點#0 (20%): 1.0s , <50M
公開 測資點#1 (20%): 1.0s , <50M
公開 測資點#2 (20%): 1.0s , <1M
公開 測資點#3 (20%): 1.0s , <10M
公開 測資點#4 (20%): 1.0s , <10M
Hint :
UVa10720 [管理者:
david942j (文旋)

ID User Problem Subject Hit Post Date