poj 2492 A Bug's Life 并查集
来源:互联网 发布:音效软件下载 编辑:程序博客网 时间:2024/06/05 06:12
裸的并查集咯
ACcode:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define maxn 100010int myset[maxn];int find_x(int x){ if(myset[x]==-1)return x; return myset[x]=find_x(myset[x]);}int main(){ int loop,tot=1; scanf("%d",&loop); while(loop--){ if(tot>1)printf("\12"); int n,m; scanf("%d%d",&n,&m); memset(myset,-1,sizeof(myset)); int flag=0; while(m--){ int a,b; scanf("%d%d",&a,&b); if(find_x(a)!=find_x(b)&&find_x(a)!=find_x(b+n)){ myset[find_x(a)]=find_x(b+n); myset[find_x(b)]=find_x(a+n); } else if(find_x(a)==find_x(b))flag=1; } printf("Scenario #%d:\n%s bugs found!\n",tot++,flag==0?"No suspicious":"Suspicious"); } return 0;}/**/
0 0
- poj 2492 A Bug's Life(并查集)
- POJ 2492 A Bug's Life(并查集)
- poj 2492 并查集 A Bug's Life
- POJ-2492 a bug's life 并查集
- poj 2492 并查集 a bug's life
- POJ 2492 A Bug's Life (并查集)
- poj 2492 A Bug's Life(种类并查集)
- poj 2492 -- A Bug's Life(并查集)
- POJ 2492 A Bug's Life (并查集)
- poj 2492 - A Bug's Life(并查集)
- 【种类并查集】-POJ-2492-A bug's life
- POJ 2492 A Bug's Life(并查集)
- POJ-2492 A Bug's Life 并查集
- [POJ 2492] A Bug's Life [扩展并查集]
- poj 2492 A Bug's Life 【并查集拓展】
- poj 并查集 - 2492 A Bug's Life
- POJ 2492 A Bug's Life 并查集
- [POJ 2492]A Bug's Life[并查集]
- Page.IsPostBack
- Spring Mybatis的分库分表方式
- Unity教程 | 手把手教你拼一个3D“魔方”
- error MSB6006: “cmd.exe”已退出,代码为 3
- 提高VS2010运行速度的技巧+关闭拼写检查
- poj 2492 A Bug's Life 并查集
- 【C#】C#委托和字典的结合使用
- Linux Shell脚本面试25问
- 服务器应对大流量请求措施
- Zookeeper以及kafka单节点服务部署
- 第十单元练习
- ZOJ 1204 Additive equations
- Anniversary party
- (N!)大数阶乘 模板