zoj 1395 Door Man 欧拉回路
来源:互联网 发布:js设置input的value 编辑:程序博客网 时间:2024/06/02 01:00
#include<stdio.h>#include<string.h>#include<vector>#include<string>#include<iostream>#include<algorithm>using namespace std;int read(char *s){ int len; for(len=0;(s[len]=getchar())!='\n'&&s[len]!=EOF;len++) ; s[len]=0; return len;}int main(){ int i,j,n,m,f,cnt[100],sum; char buf[128]; while(read(buf)) { if(strcmp(buf,"ENDOFINPUT")==0) break; sscanf(buf,"%*s %d %d",&m,&n); memset(cnt,0,sizeof(cnt)); sum=0; for(i=0;i<n;i++) { read(buf); int k=0; while(sscanf(buf+k,"%d",&j)==1) { sum++; cnt[i]++; cnt[j]++; while(buf[k]&&buf[k]==' ') k++; while(buf[k]&&buf[k]!=' ') k++; } } read(buf); int odd=0,even=0; for(i=0;i<n;i++) { if(cnt[i]%2==0) even++; else odd++; } f=0; if(even==n&&m==0) { f=1; } else if(odd>2) f=0; else { if(cnt[0]%2==1&&cnt[m]%2==1&&m!=0) f=1; else f=0; } if(f) printf("YES %d\n",sum); else printf("NO\n"); } return 0;}
0 0
- zoj 1395 Door Man 欧拉回路
- 欧拉回路-Door Man
- poj 1300 Door Man 欧拉回路
- [欧拉回路] poj 1300 Door Man
- poj1300 Door Man(欧拉回路)
- poj1300 Door Man(欧拉回路判定)
- Door Man(欧拉回路)
- poj 1300 Door Man(欧拉回路判定)
- POJ 1300 Door Man(欧拉回路判定)
- POJ1300 Door Man 欧拉回路的判断
- POJ 1300 Door Man 欧拉回路的判定
- ZOJ 1395 Door Man
- Poj 1300 Door Man (欧拉回路 通路 stream处理输入)
- POJ 1300 Door Man(欧拉回路_格式控制*)
- POJ1300 Door Man —— 欧拉回路(无向图)
- zoj 1395 && poj 1300 Door Man
- POJ 1300 Door Man(欧拉通路)
- poj 1637 & zoj 1992 混合图的欧拉回路
- 欢迎使用CSDN-markdown编辑器
- Java NIO框架Netty教程(二) – 白话概念
- 周记——20150803
- 生活中常给自己的心理暗示:
- Use of undectared identifier '_xxxx'
- zoj 1395 Door Man 欧拉回路
- struts2整合json
- 牛客网做题总结:剑指offer中题目,java版二
- CSS3.0盒模型display:-webkit-box;的使用
- 新公司入职遇到的一件事
- C++中如何理解容器适配器
- DOS format was specified but only a single line feed character was found, not 2
- instance()
- HDU-2544-最短路-模板