HDOJ question 2454 Degree Sequence of Graph G (determine whether it is a simple Graph)

Source: Internet
Author: User

HDOJ question 2454 Degree Sequence of Graph G (determine whether it is a simple Graph)
Degree Sequence of Graph GTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 1811 Accepted Submission (s): 750


Problem DescriptionWang Haiyang is a strong and optimistic Chinese youngster. although born and brought up in the northern inland city Harbin, he has deep love and yearns for the boundless oceans. after graduation, he came to a coastal city and got a job in a marine transportation company. there, he held a position as a navigator in a freighter and began his new life.

The cargo vessel, Wang Haiyang worked on, sails among 6 ports between which exist 9 routes. at the first sight of his navigation chart, the 6 ports and 9 routes on it reminded him of Graph Theory that he studied in class at university. in the way that Leonhard Euler solved The Seven Bridges of Knoigsberg, Wang Haiyang regarded the navigation chart as a graph of Graph Theory. he considered the 6 ports as 6 nodes and 9 routes as 9 edges of the graph. the graph is partitioned strated as below.



AccZ signature? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> keys + keys Bytes Bytes Vertex = "s put forward such a definition: provided that a non-negative integer sequence is the degree sequence of a graph without any parallel edge or ring, that is, a simple graph, the sequence is draw-possible, otherwise, non-dr Aw-possible. now the problem faced with Wang Haiyang is how to test whether a non-negative integer sequence is draw-possible or not. since Wang Haiyang hasn't studied Algorithm Design course, it is difficult for him to solve such a problem. can you help him?


InputThe first line of input contains an integer T, indicates the number of test cases. in each case, there are n + 1 numbers; first is an integer n (n <1000), which indicates there are n integers in the sequence; then follow n integers, which indicate the numbers of the degree sequence.


OutputFor each case, the answer shoshould be "yes" or "no" indicating this case is "draw-possible" or "non-draw-possible"


Sample Input

26 4 4 3 3 2 24 2 1 1 1

Sample Output
yesno

Source2008 Asia Regional Harbin
Recommendgaojie | We have carefully selected several similar problems for you: 2448 2452 2451 2453 ac code
#include
 
  #include
  
   #include
   
    int cmp(const void *a,const void *b){return *(int *)b-*(int *)a;}int a[10010];int main(){int t;scanf("%d",&t);while(t--){int n,i,j,sum=0;scanf("%d",&n);for(i=0;i
    
     =n)break;}if(i
     
      

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.