POJ 2492 A Bug's Life
来源:互联网 发布:网络调查问卷设计 编辑:程序博客网 时间:2024/05/20 15:39
题目大意:
现有n个元素(1 ≤ n ≤ 2,000)编号1 ~ n,以及m条断言(m ≤ 1,000,000),总共有两个不同的集合,每个元素只能属于其中一个集合,每条断言的形式为"x y",表示编号为x、y的两个元素不在同一个集合中,如果断言中有自相矛盾的情况则输出"Suspicious bugs found!",否则输出"No suspicious bugs found!"。
现有t组测例,每组测例中给出n和m,以及m条断言的内容,对于每组测例都按要求输出以上两句话,并且每组测例的输出之间空一行。
注意!!和POJ 1703 Find them, Catch them相同!!
题目链接
代码:
/* * Problem ID : POJ 2492 A Bug's Life * Author : Lirx.t.Una * Language : C * Run Time : 735 ms * Run Memory : 160 KB */ #include <memory.h>#include <stdio.h>#defineTRUE1#defineFALSE0#defineMAXN2000shortfath[MAXN + 1];charrela[MAXN + 1];intfind(int x) {intfx;introot;if ( x == fath[x] ) return x;fx = fath[x];root = find(fx);rela[x] = rela[x] ^ rela[fx];return fath[x] = root;}intmain() {intt, iscn;intn, m;inta, b;intfa, fb;inti;intflag;scanf("%d", &t);iscn = 0;while ( t-- ) {scanf("%d%d", &n, &m);for ( i = 1; i <= n; i++ ) fath[i] = i;memset(rela, 0, sizeof(rela));flag = TRUE;while ( m-- ) {scanf("%d%d", &a, &b);if ( !flag ) continue;fa = find(a);fb = find(b);if ( fa == fb )if ( rela[a] == rela[b] ) flag = FALSE;else continue;else {fath[fb] = fa;rela[fb] = rela[a] ^ rela[b] ^ 1;}}printf("Scenario #%d:\n", ++iscn);if (flag) puts("No suspicious bugs found!\n");else puts("Suspicious bugs found!\n");}return 0;}单词解释:
be consistent with:vt, 与...相一致,相符合
falsify:vt, 证明...是假的
homosexual:n, 同性恋者,同性恋的
assumption:n, 假设,设想
gender:n, 性别
feature:vt, 以...为特色(特征)
sexual behavior:n, 性行为
sexual:adj, 性的
research:vt, 调研
bug:n, 臭虫,小虫
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
- Android 关于Dialog弹出框
- poj 1416 Shredding Company
- ZOJ-1121
- 数据结构简单的停车管理系统
- First Missing Positive & Clone Graph & Sqrt(x)
- POJ 2492 A Bug's Life
- 体积雾(dx9)
- ViewGroup的onMeasure和onLayout分析
- 关于UEFI
- Android多线程分析之五:使用AsyncTask异步下载图像
- elasticsearch的一些基本概念
- 计算机视觉国外研究机构及大牛
- OCP 1Z0 053 169
- 黑马程序员_JAVA多线程_2