The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 28293 Accepted: 13787 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. T…
题目链接: http://poj.org/problem?id=2524 题意: n个人,m对人宗教相同,输出一共有多少个不同的宗教. 代码如下: #include<iostream> #include<cstdio> using namespace std; #define M 500100 int par[M]; int h[M]; int n, m; void init(int a) { for(int i = 1; i <= a; i++) { par[i] = i;…
Ubiquitous Religions Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know…
说来惭愧啊..现在才会并查集.我竟然给我妈妈讲明白并查集怎么回事了- - #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; #define maxx 50010 int set[maxx]; int find(int x) { return x == set[x] ? x : (set[x] = find(set[x])); } int main() { int n, m; int kase = 0…
Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know that there are n stud…
Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know that there are n stud…