b599. Graph Construction
標籤 : Graph erodos galloi theorem
通過比率 : 13人/15人 ( 87% ) [非即時]
評分方式:
Tolerant

最近更新 : 2015-10-21 13:28

內容

A graph is a collection of edges E and vertices V . There are many different ways to represent a graph in a computer. Graphs 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 are n vertices then n integers can represent the graph. In this problem, we are talking about simple graph which does not have same pairs of endpoints for more than one edge, and also does not have edges with the same endpoint.

An example is shown as follows. The graph can be represented as 1, 3, 2 and 2.

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 these n numbers can represent the degrees of n vertices of a graph.

輸入說明

The input contains several test cases. Each test case consists of two lines. Each test case starts a line with an integer n, 1 <= n <= 1000, where n is the number of vertices in the graph. The following line contains n numbers which represents the degrees of n vertices of the graph. Input is terminated with a single zero.

輸出說明

If the n integers can represent a graph then output 'Y'. Otherwise output 'N'. Output for each test case should be in a separate line.

範例輸入 #1
4
3 3 3 3
6
2 4 5 5 2 1
5
3 2 3 2 1
0
範例輸出 #1
Y
N
N
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 2.0s , <1M
提示 :
標籤:
Graph erodos galloi theorem
出處:
SEARCC-ISSC國際學生程式設計競賽 [管理者: spocktsai (囧rz) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」