Description

Background 

Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gender. In his experiment, individual bugs and their interactions were easy
to identify, because numbers were printed on their backs. 
Problem 

Given a list of bug interactions, decide whether the experiment supports his assumption of two genders with no homosexual bugs or if it contains some bug interactions that falsify it.

Input

The first line of the input contains the number of scenarios. Each scenario starts with one line giving the number of bugs (at least one, and up to 2000) and the number of interactions (up to 1000000) separated by a single space. In the following lines, each
interaction is given in the form of two distinct bug numbers separated by a single space. Bugs are numbered consecutively starting from one.

Output

The output for every scenario is a line containing "Scenario #i:", where i is the number of the scenario starting at 1, followed by one line saying either "No suspicious bugs found!" if the experiment is consistent with his assumption about the bugs' sexual
behavior, or "Suspicious bugs found!" if Professor Hopper's assumption is definitely wrong.

Sample Input

2
3 3
1 2
2 3
1 3
4 2
1 2
3 4

Sample Output

Scenario #1:
Suspicious bugs found! Scenario #2:
No suspicious bugs found!

Hint

Huge input,scanf is recommended.

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=2005;
int par[maxn*2]; void init(int n)
{
for(int i=0; i<=n; i++)
par[i]=i;
} int find(int x)
{
return par[x]==x?x:par[x]=find(par[x]);
} void unite(int x,int y)
{
x=find(x);
y=find(y);
if(x==y)return;
par[x]=y;
} bool same(int x,int y)
{
return find(x)==find(y);
} int main()
{
int T,tt=0,n,m;
scanf("%d",&T);
while(T--)
{
bool f=false;
scanf("%d%d",&n,&m);
init(n*2);
while(m--)
{
int x,y;
scanf("%d%d",&x,&y);
if(same(x,y)||same(x+n,y+n))
{
f=true;
}
else
{
unite(x,y+n);
unite(x+n,y);
}
}
printf("Scenario #%d:\n%s\n\n",++tt,f?"Suspicious bugs found!":"No suspicious bugs found!");
}
return 0;
}

A Bug's Life(削弱版食物链)的更多相关文章

  1. IE的CSS相关的BUG(整理一)

    本来不想弄这个ie的bug的,真的很想让它快点死掉,可是事与愿违啊,没办法,还是贴出来,以备自用. 这个网页(http://haslayout.net/css/index)上例举了所有的IE和CSS相 ...

  2. QzzmServer v2.0正式版发布

                                 V2.1升级程序已发布,具体见下文                                首先,感谢网友的热情的测评及反馈,现Qzzm ...

  3. 洛谷1525 关押罪犯NOIP2010 并查集

    问题描述 S城现有两座监狱,一共关押着N名罪犯,编号分别为1~N.他们之间的关系自然也极不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用“怨气值”(一个正整数值)来表示某两 ...

  4. CYQ.Data V4系列全面开源(2013-08-04)

    致各位.NET开发者: 考虑到本人开源作品太多,个人维护力度有限,故自2013-08-04开始,开放原本需要授权使用的V4系列的最高版本V4.55的框架源码,同时也开放相对应的辅助工具源码,自此,V4 ...

  5. Apache HTTP Server 2.2.26 发布

    Apache遗留产品线2.2.26发布.2013-11-13 之前的版本是2013-07-02的2.2.25 同样先在开发目录下放出下载,然后放到正式目录下.修正了大量的Bug.目前的稳定版2.4系列 ...

  6. 关于js运动的一些总结

    js运动实现,有两种.一种是速度版,另一种是时间版. 速度版是通过对速度的加减乘除,得出元素的运动数据.时间版是通过对时间进行Tween公式运算,得出元素的运动数据. 速度版运动优点:容易在运动过程中 ...

  7. linux知识点

    通过gui来使用通过api来使用通过cli来使用通过tui来使用 进程不在,但tcp连接还一直存在的解决办法--tcpkill命令 http://www.centoscn.com/CentOS/Int ...

  8. Hadoop2以来的历次升级(不含2.2.0及以下)

    2015年7月06:release 2.7.1(稳定)请参阅 Hadoop 2.7.1发布说明 对131个bug修复和列表 从先前版本2.7.0补丁. 请看看 2.7.0章节列表的增强功能启用 第一个 ...

  9. iOS断点及打印日志

    首先,最简单的断点就是在Xcode项目文件中任意一行行号那点一下,就是加了一个断点 再次点击会变成浅蓝色,表示disable掉了 disable掉的断点不会起作用,但会在左上角蓝色的标签那留下记录,这 ...

随机推荐

  1. Vertical roller mill from SBM

    Vertical roller mill has many different forms, but it works basically the same. All of these forms o ...

  2. iOS开发 - 3D Touch 应用系列一 - Quick Actions 创建桌面 Icon 快捷方式

    个言 很久没发随笔了,有一年多了吧.期间也曾想继续去写随笔,但是因为各种原因而耽搁了.最近又想了一下,还是有很多东西想要写,想要分享,想要记录下来的东西.之后我也会不断写随笔,但不止于 iOS 的方向 ...

  3. VS2015配置使用Sqlite以及EF6框架记录

    项目中需要使用到Sqlite本地数据库保存数据,以防止离线情况下设备的正常使用. 一.下载vs2015下的sqlite插件,并安装 插件下载页面:http://system.data.sqlite.o ...

  4. 2019年我的nodejs项目选型

    选型项目比较激进.发现基于 go 语言的工具变多了.

  5. 使用compiz出现奔溃的一些应急办法

    Linux Mint 17.1 CompizConfig is also installed by default so you can configure every aspect of Compi ...

  6. springboot mybatis 自动生成代码(maven+IntelliJ IDEA)

    1.在pom文件中加入需要的依赖(mybatis-generator-core) 和 插件(mybatis-generator-maven-plugin) <dependency> < ...

  7. struts2的执行流程

    在浏览器端输入相应的访问地址>>>>把请求发送给tomact>>>>tomact判断应该交给那个webApplication>>>&g ...

  8. cocos2d-x 配置教程

    下载cocos2d-x并解压(解压的路径不要带空格,不然以后用cygwin编译工程的时候会出现错误),我的解压到了D:\cocos2d-2.1rc0-x-2.1.2(我的版本是cocos2d-2.1r ...

  9. Excel2Dataset

    //获取用户打开的Excel文档路径 private stringkkk() { OpenFileDialog selectFile = new OpenFileDialog(); selectFil ...

  10. 无法通过CTRL+空格及SHIFT+CTRL调出输入法的解决方案

    打开任务管理器: 运行:CTFMON.EXE