uva 10720 Graph Construction
2013-09-02 18:25
232 查看
题意:求是否可以构成图,用到了这个Havel定理
点击打开链接
点击打开链接
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 10002; int cmp(const void *a,const void *b) { return *(int *)b - *(int *)a; } int a[MAXN]; int solve(int n) { for (int i = 0; i < n; i++) { qsort(&a[i],n - i,sizeof(a[0]),cmp); if (a[i] >= n) return 0; if (a[i] == 0) return 1; for (int j = i + 1; j <= a[i] + i; j++) { --a[j]; if (a[j] < 0) return 0; } } return 1; } int main() { int n; while (scanf("%d",&n) != EOF && n) { for (int i = 0; i < n; i++) scanf("%d",&a[i]); if (solve(n)) printf("Possible\n"); else printf("Not possible\n"); } return 0; }
相关文章推荐
- UVa10720
- uva 10720 - Graph Construction(贪心-Havel-Hakimi)
- UVa 10720 - Graph Construction
- UVA 10720 - Graph Construction
- UVa10720 ( Graph Construction)(判断是否可化为简单图)
- uva 10720 Graph Construction
- UVa 10720 - Graph Construction
- uva 10720 Graph Construction()
- UVA 10720 Graph Construction
- uva 10720 Graph Construction
- uva 10720 - Graph Construction
- [贪心]UVA10720 - Graph Construction
- UVA 10720 Graph Construction
- UVa 10720 - Graph Construction(Havel-Hakimi定理)
- UVa10720 - Graph Construction
- UVA10720- Graph Construction
- UVA 10720 Graph Construction
- uva10720(Graph Construction)贪心+havel定理
- uva 10720
- uva10720 - Graph Construction(图重建)