10720 - Graph Construction
来源:互联网 发布:笔记本按ubuntu黑屏 编辑:程序博客网 时间:2024/05/16 14:03
描述:因为是简单图,所以先判断角度和是否为偶数,然后再需要用优先队列,从大到小进行排除#include <iostream>#include <cstdio>#include <cstdlib>#include <queue>using namespace std;priority_queue <int> p;int num[10010];int main(){ // freopen("a.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { if(!n) break; int sum=0,x; while(!p.empty()) p.pop(); for(int i=0; i<n; i++) { scanf("%d",&x); if(x%2==1) sum++; if(sum%2==0) sum=0; if(x) p.push(x); } if(!sum) { while(!p.empty()) { x=0; int c=p.top(); p.pop(); while(!p.empty()) { if(c==0) break; if(p.top()>0) { num[x++]=p.top()-1; c--; p.pop(); } } if(c>0) { sum=1; break; } for(int i=0; i<x; i++) if(num[i]>0) p.push(num[i]); } if(!sum) printf("Possible\n"); else printf("Not possible\n"); } else printf("Not possible\n"); } return 0;}
- UVa 10720 - Graph Construction
- UVa 10720 - Graph Construction
- uva 10720 - Graph Construction
- uva 10720 - Graph Construction
- UVA 10720 - Graph Construction
- 10720 - 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
- UVA 10720 Graph Construction
- uva 10720 Graph Construction
- UVA 10720 Graph Construction
- 10720 - Graph Construction
- uva 10720 Graph Construction()
- uva 10720 Graph Construction(贪心)
- Failed to load JavaHL Library.
- iphone 命令行编译
- 【Android工具】被忽略的UI检视利器:Hierarchy Viewer
- 双网卡或多网卡组播 (ZT)
- thinkphp中的各种方法
- 10720 - Graph Construction
- QQ验证码识别(版本较旧,思路才是王道)
- 人生无根蒂,飘如陌上尘.
- java分页技术
- Android4.0 480DP屏幕使状态栏始终显示
- 实时storm程序架构图
- UVA 11137 Ingenuous Cubrency
- ibm competency
- linux设备驱动归纳总结(十一):写个简单的看门狗驱动