zoj 3321 Circle (4)
来源:互联网 发布:js当前时间加一年 编辑:程序博客网 时间:2024/04/30 06:22
这道题,我用的是kruskal里的东西来做的,很遗憾的是当时或许太激动了,把m错写成n了,找了好久都没找到错误在那,最后提交4次才过,可惜可惜啊!
#include<stdio.h>typedef struct{ int x; int y;}xx;xx node[30];int pre2[30];int find(int x) { while(x!=pre2[x]) x=pre2[x]; return x; } int unio(int n){ int i,a,b,sum=0; for(i=0;i<n;i++) { a=find(node[i].x); b=find(node[i].y); if(a!=b) { sum++; pre2[b]=a; } else { sum++; break; } } return sum;}int main(){ int n,m,i,pre1[30],p,num; while(scanf("%d%d",&n,&m)!=EOF) { p=1; num=0; for(i=1;i<=n;i++) { pre1[i]=0; pre2[i]=i; } for(i=0;i<m;i++) { scanf("%d%d",&node[i].x,&node[i].y); pre1[node[i].x]++; pre1[node[i].y]++; } if(n!=m||n<3) p=0; else { for(i=1;i<=n;i++) if(pre1[i]!=2) { p=0; break; } if(p) { num=unio(n); if(num!=n) p=0; } } if(p) printf("YES\n"); else printf("NO\n"); } return 0; }
- zoj 3321 Circle (4)
- zoj 3321 Circle
- ZOJ 3321 Circle【模拟】
- ZOJ 3321 Circle
- zoj 3321 - Circle
- ZOJ 3321Circle
- ZOJ 3321 Circle(并查集啊)
- zoj Circle
- zoj Circle
- ZOJ 3321 Circle(并查集)
- zoj 3321 Circle【并查集】
- zoj 1450 Minimal Circle
- zoj 1450 Minimal Circle(最小覆盖圆)
- zoj 1450 Minimal Circle(最小包围圆)
- zoj 3058 Circle and Ring
- zoj 1090 The Circumference of the Circle(海伦公式+正弦定理)
- ZOJ 1090 The Circumference of the Circle(计算三角形的外接圆)
- ZOJ 3058 Circle and Ring(圆和圆环的相交面积)
- C# Dlllmport 学习
- Map 控件深入学习
- (转载)Windows PowerShell 講座 (1)—指令、重導、別名
- AWK Notes
- Java compiler level does not match the version of the installed Java project fac
- zoj 3321 Circle (4)
- (转载)Windows PowerShell 講座 (2)—自訂工作環境
- 计算机图形学国际知名会议与期刊
- 推送通知
- JAVA调用DLL的两种方法(作者不详,如有冒犯请速联系我,我只是用来参考)
- Linux环境编程--fflush(stdout)有什么作用
- (转载) Windows PowerShell ---流程控制
- JFreeChart
- 对比SQL SERVER,ORACLE,DB2视图建立语句。