The Suspects POJ 1611】的更多相关文章

链接: http://poj.org/problem?id=1611 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#problem/B 代码: #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 30005 int a[N]; int n, m; int Find(int x) { if(a[x]!=x) a[x] =…
The Suspects Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others. In…
Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others.In the Not-Spread…
病毒扩散问题,SARS病毒最初感染了一个人就是0号可疑体,现在有N个学生,和M个团队,只要团队里面有一个是可疑体,那么整个团队都是可疑体,问最终有多少个人需要隔离... 再简单不过的并查集,只需要不断的合并每一行就行可,到最后查询一个所有与0相同的树根就行了 ////////////////////////////////////////////////////////////////// #include<stdio.h> ; ; i<N; i++)             f[i] …
题目地址: http://poj.org/problem?id=1611 题目内容: The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 24253   Accepted: 11868 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recogni…
题目链接:http://poj.org/problem?id=1611 题意:给定n个人和m个群,接下来是m行,每行给出该群内的人数以及这些人所对应的编号.需要统计出跟编号0的人有直接或间接关系的人数总共有多少. 这又是一条并查集的应用.难点是如何统计出与0有关系的总人数,即包含0的集合内元素的总个数.我的方法是用了两次merge,第一次merge单纯地将同一群内的元素连边,当然该群内的元素的祖先有可能是别的群内的元素,连边的规则是大的元素指向小的元素:第二次merge则把第一次筛选出来的集合中…
题目:http://poj.org/problem?id=1611 0号是病原,求多少人有可能感染 #include<stdio.h> #include<string.h> #define maxn 50000 int u,v,bin[maxn]; int find(int x) { return bin[x]==x?x:(bin[x]=find(bin[x])); }; int main() { int n,m,i,j,x,y,k,sum,t; ||m!=)) { sum=; ;…
题目链接 http://poj.org/problem?id=1611 题意 给出 n, m 有n个人 编号为 0 - n - 1 有m组人 他们之间是有关系的 编号为 0 的人是 有嫌疑的 然后和 编号为0的人有关系 或者 和 编号为0的人有关系的人 有关系的 都是有嫌疑的 找出共有多少人有嫌疑 思路 将所有有关系的人 合并 然后 去查找 所有的人的根节点 如果和编号为0的人的根节点 相同 他就是有关系的 AC代码 #include <cstdio> #include <cstring…
http://poj.org/problem?id=1611 [Accepted] #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include <string> using namespace std; ; int fa[maxn]; int n,m; int a[maxn]; void init() { ;i<n;i++) { fa[…
原题链接:http://poj.org/problem?id=1611 简单记录下并查集的模板 #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <queue> #include <cmath> #define ll l…