bzoj1116 [POI2008]CLO(记录带环连通块)
来源:互联网 发布:移动刷流量软件 编辑:程序博客网 时间:2024/06/05 21:59
基本同bzoj1854 还是如果一个块内有环,则这一个块内都可以满足,否则必定有一个点不满足。(这题题意有毒,读了半天才明白 是你可以把一些边变成单向边,其他的可以删去。)
#include<cstdio>#include<cstring>int const N=100010;int n,m,fa[N];bool v[N];int find(int x){ return fa[x]==x?x:fa[x]=find(fa[x]);}void merge(int xx,int yy){ if(v[xx]||v[yy]) v[xx]=1,v[yy]=1; fa[xx]=yy;v[xx]=1;}int main(){ memset(v,0,sizeof(v)); scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) fa[i]=i; while(m--){ int x,y; scanf("%d%d",&x,&y); int xx=find(x),yy=find(y); if(xx==yy) v[xx]=1; else merge(xx,yy); } for(int i=1;i<=n;++i) if(!v[i]){ puts("NIE");return 0; } puts("TAK"); return 0;}
阅读全文
0 0
- bzoj1116 [POI2008]CLO(记录带环连通块)
- bzoj1116 [POI2008]CLO
- 【BZOJ1116】[POI2008]CLO【BFS】
- bzoj1116: [POI2008]CLO
- BZOJ1116: [POI2008]CLO
- 【bzoj1116】 [POI2008]CLO
- bzoj1116 [POI2008]CLO
- BZOJ1116: [POI2008]CLO 并查集
- POI2008 CLO
- BZOJ1116 CLO [并查集]
- 【BZOJ 1116】 [POI2008]CLO
- BZOJ 1116: [POI2008]CLO
- 1116: [POI2008]CLO|深度搜索
- BZOJ 1116: [POI2008]CLO BZOJ
- 1116: [POI2008]CLO (并查集)
- 【并查集】【bzoj 1116】: [POI2008]CLO
- BZOJ 1116 POI2008 CLO 并查集
- BZOJ 1116 [POI2008]CLO 并查集
- 统计字符的个数
- seekBar 的用法
- sublime Text 3 emmet自定义HTML模板
- 机器学习理论(学习笔记)
- BeanUtils.copyProperties()用法
- bzoj1116 [POI2008]CLO(记录带环连通块)
- 死锁的条件
- linux下基本操作记录mongodb
- OpenCv基础知识梳理总结
- Echarts加载自定义地图geoJson
- SQL 查询存储过程、视图内容
- HDU 5253 连接的管道(kruskal+状态压缩+二维转化为一维)
- ES6的Lambda表达式
- CentOS7.3安装rocketmq