Traveling
来源:互联网 发布:又当黑客又当程序员 编辑:程序博客网 时间:2024/05/17 03:24
Traveling
时间限制: 1 Sec 内存限制: 128 MB提交: 15 解决: 5
[提交][状态][论坛]
题目描述
SH likes traveling around the world. When he arrives at a city, he will ask the staff about the number of cities that connected with this city directly. After traveling around a mainland, SH will collate data and judge whether the data is correct.
A group of data is correct when it can constitute an undirected graph.
输入
There are multiple test cases. The first line of each test case is a positive integer N (1<=N<=10000) standing for the number of cities in a mainland. The second line has N positive integers a1, a2, ...,an. ai stands for the number of cities that connected directly with the ith city. Input will be ended by the END OF FILE.
输出
If a group of data is correct, output "YES" in one line, otherwise, output "NO".
样例输入
样例输出
提示
来源
辽宁省赛2014
#include<iostream>using namespace std;int a[10010];int main(){ int n; while(cin>>n){ int i,j; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(a[i]>0 && a[j]>0){ a[i]--; a[j]--; } } if(a[i]!=0){ cout<<"NO"<<endl; break; } } if(i>=n) cout<<"YES"<<endl; } return 0;}
- Traveling
- Traveling
- Traveling Light
- Traveling light
- Traveling Light - 轻装前行
- jTibet Traveling Tibet
- Kernel Packet Traveling Diagram
- Kernel Packet Traveling Diagram
- Poj3033 Traveling Salesman(搜索)
- The Traveling Salesman Problem
- UESTC 1852 Traveling Cellsperson
- BNU33653:Traveling Cellsperson
- 2014辽宁省赛 Traveling
- POJ2686 Traveling by Stagecoach
- Guiyang, Diverse traveling experience
- UESTC 1852 Traveling Cellsperson
- Traveling 【图的性质】
- codeforces546E Soldier and Traveling
- 大型网站技术架构(一)--大型网站架构演化
- 2014百度之星资格赛题解
- Eclipase +PyDev(64位) 配置使用
- jsp插入到数据库的中文汉字变成问号乱码的处理办法(mysql)
- 九度 题目1283:第一个只出现一次的字符
- Traveling
- matlab imresize 改变图像大小
- 图像拉普拉斯金字塔融合(Laplacian Pyramid Blending)
- 关于C++的一些问题的整理
- 实时视觉系统
- linux命令大全
- Humble Numbers--奇怪的错误
- [ACM] hdu 1251 统计难题 (字典树)
- LINUX下安装配置Android开发环境(Eclipse)