A Bug
A Bug
| Time Limit: 1000MS | Memory Limit: 65535KB |
| Submissions: 231 | Accepted: |
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!
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
const int MAX = ;
int father[MAX];
int find(int x)
{
return x==father[x]?x:find(father[x]);
}
bool unionsearch(int x,int y)
{
int fx = find(x);
int fy = find(y);
if(fx==fy)
{
return false;
}
else
{
father[fy] = fx;
return true;
}
}
int main()
{
int num;
scanf("%d",&num);
int z=;
while(z<=num)
{
memset(father,,sizeof(father));
int n,m;
scanf("%d %d",&n,&m);
for(int i=; i<=n; i++)
father[i] = i;
bool flag =false;
for(int i= ; i<=m; i++)
{
int a,b;
scanf("%d %d",&a,&b);
if(unionsearch(a,b))
{
}
else
{
flag = true;
}
}
if(!flag)
printf("Scenario #%d:\nNo suspicious bugs found!\n",z);
else
printf("Scenario #%d:\nSuspicious bugs found!\n",z);
z++;
}
return ;
}
A Bug的更多相关文章
- Tomcat一个BUG造成CLOSE_WAIT
之前应该提过,我们线上架构整体重新架设了,应用层面使用的是Spring Boot,前段日子因为一些第三方的原因,略有些匆忙的提前开始线上的内测了.然后运维发现了个问题,服务器的HTTPS端口有大量的C ...
- a标签点击跳转失效--IE6、7的奇葩bug
一般运用a标签包含img去实现点击图片跳转的功能,这是前端经常要用到的东西. 今天遇到个神奇的bug:如果在img上再包裹一层div,而且div设置了width和height,则图片区域点击时,无任何 ...
- 关于 Chrome 浏览器中 onresize 事件的 Bug
我在写插件时用到了 onresize 事件,在反复地测试后发现该事件在 Chrome 及 Opera(内核基本与 Chrome 相同,以下统称 Chrome)浏览器打开时就会执行,这种情况也许不能算作 ...
- Chrome出了个小bug:论如何在Chrome下劫持原生只读对象
Chrome出了个小bug:论如何在Chrome下劫持原生只读对象 概述 众所周知,虽然JavaScript是个很灵活的语言,浏览器里很多原生的方法都可以随意覆盖或者重写,比如alert.但是为了保证 ...
- 一个粗心的Bug,JSON格式不规范导致AJAX错误
一.事件回放 今天工作时碰到了一个奇怪的问题,这个问题很早很早以前也碰到过,不过没想到过这么久了竟然又栽在这里. 当时正在联调一个项目,由于后端没有提供数据接口,于是我直接本地建立了一个 json ...
- 了不起的 nodejs-TwitterWeb 案例 bug 解决
了不起的nodejs算是一本不错的入门书,不过书中个别案例存在bug,按照书中源码无法做出和书中相同效果,原本兴奋的心情掺杂着些许失落. 现在我们看一下第七章HTTP,一个Twitter Web客户端 ...
- 应该是Angular2的一个bug?
为了应对未来的趋势,及时赶上下一趟互联网技术,我最近也在通过具体项目研究angular2,首先必须要吐槽的是,学习angular2的成本本身不高,但是一堆的工具.配置实在让人 很是焦灼,就像asp.n ...
- 记录一次bug解决过程:数据迁移
一 总结 不擅长语言表达,勤于沟通,多锻炼 调试MyBatis中SQL语法:foreach 问题:缺少关键字VALUES.很遗憾:它的错误报的让人找不着北. 二 BUG描述:MyBatis中批量插入数 ...
- 关于MJRefresh的下拉加载数据bug
当没有更多数据的时候显示NoMoreData 我的理解是先结束刷新再显示没有更多 今天之前一直没发现有问题 贴之前的代码 [self.collectionView reloadData]; [self ...
- [异常特工]android常见bug跟踪
前言 对app的线上bug的收集(友盟.云捕等)有时会得到这样的异常堆栈信息:没有一行代码是有关自身程序代码的.这使得对bug的解决无从下手,根据经验,内存不足OOM,Dialog关闭,ListVie ...
随机推荐
- android sdk manager下载慢可以使用代理信息
mirrors.neusoft.edu.cn 80
- 浅谈对git的认识
在上大二之前我根本不知道git是什么,根本不知道它有什么功能,以及应用于那个领域,那天老师说让我们了解一些它,并对其进行一下学习.我瞬间就蒙了,但是我并没有把其抛在脑后,而是通过在其它方式,对其进行了 ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors
题目链接: http://codeforces.com/contest/673/problem/C 题解: 枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了. 暴力n*n. ...
- JS学习笔记-1--基本知识和注意事项
1.JS开始的目的主要是验证表单的输入验证 2.是一种具有面向对象能力的.解释型语言.是基于事件驱动的相对较安全的客户端脚本语言 3.JS 特点:松散型:变量不具备一个明确的类型: 对象属性:把属 ...
- 跨平台base64数据传输注意问题
今天用base64编码传输json串,android端那边始终看不到图片! 首先发现android端接收的json串长度不一致,仔细研究发现android端接收到的json数据里把服务器数据里的&qu ...
- 使用WCF服务的客户端出现maxReceivedMessageSize异常
使用WCF服务的客户端出现maxReceivedMessageSize异常解决方案 当使用WCF的客户端调取的数据过多时,会出现这个异常.一般情况下,系统默认值是65536,大约容纳100-200条左 ...
- awk 统计数据在文件中的出现次数
突然发现awk原来可以统计同一数据在要处理的文件中所出现的次数.原来的时候为了分析数据还自己写程序,哎,无语,当时还以为自己多强,手工分析不过来的东西写程序处理.现在想来实在是年少轻狂.解决问题嘛,不 ...
- 远程数据源Combobox
Ext.define('bookInfo', { extend: 'Ext.data.Model',//新类继承自model fields: [{ name: 'b ...
- iOS-CAEmitterLayer(粒子效果)
扩展:https://github.com/lichtschlag/Dazzle ; , , , ); , ); .f; .f; ; .f; .f; ...
- iOS生成本地随机验证码
原文链接:http://www.cnblogs.com/jerehedu/p/4527707.html 效果图: