博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2492 A Bug's Life (并查集)
阅读量:6266 次
发布时间:2019-06-22

本文共 2104 字,大约阅读时间需要 7 分钟。

A Bug's Life
Time Limit: 10000MS   Memory Limit: 65536K
Total Submissions: 26599   Accepted: 8676

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

23 31 22 31 34 21 23 4

Sample Output

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

Hint

Huge input,scanf is recommended.

Source

, Darmstadt, Germany
1 //Accepted    140K    735MS    C++    821B    2014-03-28 17:12:00 2 /* 3  4     分类并查集,思想和2492差不多。  5  6 */ 7 #include
8 #define N 2000 9 int set[2*N+1];10 int find(int x)11 {12 if(x==set[x]) return x;13 return set[x]=find(set[x]);14 }15 int main(void)16 {17 int t,n,m,a,b,k=1;18 scanf("%d",&t);19 while(t--)20 {21 scanf("%d%d",&n,&m);22 for(int i=0;i<=n+N;i++) set[i]=i;23 int flag=0;24 for(int i=0;i

 

转载于:https://www.cnblogs.com/GO-NO-1/p/3631092.html

你可能感兴趣的文章
makefile编写---单个子目录编译模板
查看>>
Oracle DB_LINK如何使用
查看>>
cv resource
查看>>
关于加快INSERT语句执行速度和HINT /*+ append */及/*+ append nologging */的使用
查看>>
JDK源代码学习系列07----Stack
查看>>
firefox
查看>>
PS批处理的使用
查看>>
七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC 【转】
查看>>
Quartz作业调度框架
查看>>
腾讯云下安装 nodejs + 实现 Nginx 反向代理
查看>>
js-权威指南学习笔记13
查看>>
《超级时间整理术》晨读笔记
查看>>
Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner
查看>>
Delphi IdTCPClient IdTCPServer 点对点传送文件
查看>>
Delphi中使用ActiveX的一些心得
查看>>
QT5.8.0+MSVC2015安装以及环境配置(不需要安装VS2015)
查看>>
(原創) C/C++的function prototype和header file (C/C++) (C)
查看>>
深入理解JavaScript系列(29):设计模式之装饰者模式
查看>>
程序员的罪与罚
查看>>
SQL*LOADER错误总结
查看>>