#include<iostream>
#include<stdio.h>
#define MAXN 2050
using namespace std; int pre[MAXN];
int opp[MAXN]; void init(int n)
{
int i;
for(i = ; i <= n; ++ i)
{
pre[i] = i;
opp[i] = -;
}
} int find_pre(int x)
{
if(pre[x] != x)
{
pre[x] = find_pre(pre[x]);
}
return pre[x];
} int comb(int x,int y)
{
if(x == -)
return y;
if(y == -)
return x;
pre[x] = y;
return y;
} int main()
{
//freopen("acm.acm","r",stdin);
int test;
int n;
int m;
int i;
int u;
int v;
int temp1;
int temp2;
bool boo;
bool bo;
int k;
scanf("%d",&test);
for(k = ; k < test; ++ k)
{
scanf("%d%d",&n,&m);
init(n);
boo = false; cout<<"Scenario #"<<k+<<":"<<endl;
for(i = ; i < m; ++ i)
{
bo = false;
scanf("%d%d",&u,&v);
temp1 = u;
temp2 = v;
if(i != )
{
temp1 = find_pre(temp1);
temp2 = find_pre(temp2);
if(temp1 == temp2)
{
boo = true;
// bo = true;
}
}
if(!boo)
{
u = find_pre(u);
v = find_pre(v);
temp1 = comb(u,opp[v]);
temp2 = comb(opp[u],v);
opp[temp1] = temp2;
opp[temp2] = temp1;
}
}
if(boo)
{
cout<<"Suspicious bugs found!"<<endl;
}
else
{
cout<<"No suspicious bugs found!"<<endl;
}
cout<<endl;
}
}

POJ 2492的更多相关文章

  1. POJ 2492 并查集扩展(判断同性恋问题)

    G - A Bug's Life Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  2. POJ 2492 并查集应用的扩展

    A Bug's Life Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 28651 Accepted: 9331 Descri ...

  3. A Bug's Life POJ - 2492 (带权并查集)

    A Bug's Life POJ - 2492 Background Professor Hopper is researching the sexual behavior of a rare spe ...

  4. hdu - 1829 A Bug's Life (并查集)&&poj - 2492 A Bug's Life && poj 1703 Find them, Catch them

    http://acm.hdu.edu.cn/showproblem.php?pid=1829 http://poj.org/problem?id=2492 臭虫有两种性别,并且只有异性相吸,给定n条臭 ...

  5. POJ 2492 A Bug's Life(并查集)

    http://poj.org/problem?id=2492 题意 :就是给你n条虫子,m对关系,每一对关系的双方都是异性的,让你找出有没有是同性恋的. 思路 :这个题跟POJ1703其实差不多,也是 ...

  6. poj 2492(关系并查集) 同性恋

    题目;http://poj.org/problem?id=2492 卧槽很前卫的题意啊,感觉节操都碎了, t组测试数据,然后n,m,n条虫子,然后m行,每行两个数代表a和b有性行为(默认既然能这样就代 ...

  7. (并查集)A Bug's Life -- POJ -- 2492

    链接: http://poj.org/problem?id=2492 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#probl ...

  8. POJ 2492 A Bug's Life(带权并查集)

    题目链接:http://poj.org/problem?id=2492 题目大意:有n只虫子,m对关系,m行每行有x y两个编号的虫子,告诉你每对x和y都为异性,先说的是对的,如果后面给出关系与前面的 ...

  9. POJ 2492 (简单并查集) A Bug's Life

    题意:有编号为1~n的虫子,开始假设这种昆虫是异性恋.然后已知xi 和 yi进行交配,根据已知情况分析能否推理出其中是否有同性恋 这道题和 POJ 1182 食物链 十分相似,不过在更新与父节点关系的 ...

  10. (简单) POJ 2492 A Bug's Life,二分染色。

    Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs ...

随机推荐

  1. PC Access的使用

    需要copy xxx.dll  到windows/syswow64 目录下 运行com注册 启动电脑后,自动锁定(在启动目录下架锁定程序) using System; using System.Col ...

  2. mysql学习之路_乱码问题

    中文数据问题: 中文数据问题本质就说字符集问题, 计算机只识别二进制,人类识别符号:需要友谊个二进制与字符对应关系(字符集). 报错:服务器没有识别对应的四个字节. 服务器认为的数据是utf—8,一个 ...

  3. 链家web前端面试

    共有三轮面试,每个面试官的第一个问题都是:介绍一个你觉着比较出彩的项目 第一轮面试: 因为公司项目没什么亮点,很传统的pc端,美女面试官就说让讲一下我用react的私人项目; 问了很多都是关于reac ...

  4. 二级缓存EhCache在几种应用技术的配置方法和步骤总结

    一:Spring和Ehcache缓存集成 业务问题:如果仓库不经常变动,大量进出库,总是需要查询仓库列表 (列表重复) ,使用缓存优化 ! 阅读spring规范29章节 第一步: 导入ehcache的 ...

  5. 笔记 Bioinformatics Algorithms Chapter7

    一.Lloyd算法 算法1 Lloyd Algorithm k_mean clustering * Centers to Clusters: After centers have been selec ...

  6. Java安全技术

    分类     Java平台安全,即JRE安全     开发Java程序(普通程序,服务,applet)安全,即提供安全的开发工具和服务.   用法     用签名和安全策略控制远程的资源访问

  7. C++二级指针第一种内存模型(指针数组)

    二级指针第一种内存模型(指针数组) 指针的输入特性:在主调函数里面分配内存,在被调用函数里面使用指针的输出特性:在被调用函数里面分配内存,主要是把运算结果甩出来 指针数组 在C语言和C++语言中,数组 ...

  8. 各版本.NET委托的写法回顾(转)

    转自:http://www.csharpwin.com/csharpspace/7548r2766.shtml 在<关于最近面试的一点感想>一文中,Michael同学谈到他在面试时询问对方 ...

  9. 卷积神经网络(CNN)之一维卷积、二维卷积、三维卷积详解

    作者:szx_spark 由于计算机视觉的大红大紫,二维卷积的用处范围最广.因此本文首先介绍二维卷积,之后再介绍一维卷积与三维卷积的具体流程,并描述其各自的具体应用. 1. 二维卷积 图中的输入的数据 ...

  10. JMS 消息队列

    1.jms  broker服务器:Broker:消息队列核心,相当于一个控制中心,负责路由消息.保存订阅和连接.消息确认和控制事务