题意:有编号为1到n的学生,然后有m组调查,每组调查中有a和b,表示该两个学生有同样的宗教信仰,问最多有多少种不同的宗教信仰 简单并查集 //#define LOCAL #include <iostream> #include <cstdio> #include <cstring> using namespace std; + ; int parent[maxn], n, m; int GetParent(int x) { return parent[x] == x ?…
#include<stdio.h> #define N 31000 int pre[N]; int find(int x) { if(x!=pre[x]) pre[x]=find(pre[x]); return pre[x]; } int main() { int n,m,i,k,s,t; while(scanf("%d%d",&n,&m),n||m){ for(i=0;i<=n;i++) pre[i]=i; …
The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 32781 Accepted: 15902 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. T…
Farm Irrigation Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 6 Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Benny has a spacious fa…