#include<bits/stdc++.h>
using namespace std;int a[10010];intmain(){int T, n, tot, ans;scanf("%d",&T);while(T--){scanf("%d",&n);
tot =0;for(int i =1; i <= n; i++)scanf("%d", a+i), tot += a[i];if(tot&1){// 可图化判定printf("no\n");continue;}// 可简单图化判定for(int i =1; i <= n; i++){sort(a+i, a+n+1,[](int x,int y){return x > y;});int m = a[i];if(m <0|| m > n-i)break;
a[i]=0;for(int j =1; j <= m; j++) a[i+j]--;}
ans =1;for(int i =1; i <= n && ans; i++){if(a[i]) ans =0;}printf("%s\n", ans?"yes":"no");}return0;}
hdu 2454 Degree Sequence of Graph G(Havel-Hakimi算法)
Degree Sequence of Graph G分析度序列:若把图 G 所有顶点的度数排成一个序列 d,则称 d 为图 G 的度序列简单图:无平行边、无自环(ring)【定义】可图化:给定一个非负整数序列d={d1,d2,…dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化;可简单图化:给定的度序列可图化后,若得到的图可以是简单图,则称此序列可简单图化;可图化判定: (d1+d2+…+dn)%2 = 0。 构造方法:简单地把奇数度的点配对,其它自环;可简单图化判定