HDU 2454 Degree Sequence of Graph G(Havel-Hakimi定理,图论基础)
来源:互联网 发布:淘宝代收货要钱吗 编辑:程序博客网 时间:2024/06/16 22:46
题意:判断是否可以构成图,简单的Havel-Hakimi定理的运用)
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=1005;struct node{ int degree; int index;}v[maxm];int cmp(node p,node q){ return p.degree>q.degree;}int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&v[i].degree); v[i].index=i; } int ok=1; for(int k1=0;k1<n;k1++) { sort(v,v+n,cmp); int id=v[k1].degree; int i=v[k1].index; if(id>n-k1-1) { ok=0; break; } for(int k2=1;k2<=id;k2++) { int j=v[k2+k1].index; if(v[k2+k1].degree<=0) { ok=0; break; } v[k1+k2].degree--; } if(!ok) { break; } } if(ok) { printf("yes\n"); } else { printf("no\n"); } } return 0;}
1 0
- HDU 2454 Degree Sequence of Graph G(Havel-Hakimi定理,图论基础)
- HDU 2454 Degree Sequence of Graph G(Havel定理 判断简单图的存在)
- HDU 2454 Degree Sequence of Graph G (可简单图化的判定 havel定理)
- hdu2454 Degree Sequence of Graph G (Havel-Hakimi定理,可图化判定)
- HDOJ2454(Degree Sequence of Graph G)(Havel-Hakimi定理判断所给序列是否可化成简单图)
- HDU 2454 Degree Sequence of Graph G(Heavel定理)
- hdu2454 Degree Sequence of Graph G(havel定理)
- hdu 2454 Degree Sequence of Graph G
- hdu 2454 Degree Sequence of Graph G
- hdu 2454 Degree Sequence of Graph G (判断简单图)
- Degree Sequence of Graph G(Hdu_oj 2454)
- uva10720 - Graph Construction(Havel-Hakimi定理)
- HDOJ题目2454 Degree Sequence of Graph G(判断是否是简单图)
- UVA-10720 Graph Construction(Havel-Hakimi定理)
- ZOJ 3732 Graph Reconstruction (Havel-Hakimi定理)
- 图论之Havel-Hakimi定理运用
- zoj 3732 Graph Reconstruction(Havel-Hakimi定理)
- 10720Graph Construction(Havel-Hakimi定理 )
- 中间人攻击——DNS欺骗的原理、实战及防御
- 自定义cell(通过代码,cell得高度不一致)
- 一次完整的HTTP事务是怎样一个过程?
- 数据备份
- (实用)dialog中点击按钮禁止其消失
- HDU 2454 Degree Sequence of Graph G(Havel-Hakimi定理,图论基础)
- iOS新闻客户端开发教程1--项目框架搭建
- 【以太网数据结构】地址解析协议ARP
- 桌面云的四大协议解析
- jQuery ajax - serialize() 方法的使用
- 17.1.2 Replication Formats
- 猴子选大王(约瑟夫环的使用,第一个不是报数人)
- [leetcode]Sort Colors
- jQuery 2.0.3 源码分析 事件体系结构