my code: #include <cstdio>#include <cstring>#include<iostream>using namespace std;int find(int num,int A []){while(num!=A[num])//{ num = A[num];return num;}// bool follow(int a,int b,int A[]){int i = find(a,A);int j = find(b,A);//cout<…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1213 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the fri…
How Many Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14081    Accepted Submission(s): 6912 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinn…
Description 严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁.为了减少传播给别人的机会, 最好的策略是隔离可能的患者. 在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体.同一组的学生经常彼此相通,一个学生可以同时加入几个小组.为了防止非典的传播,NSYSU收集了所有学生团体的成员名单.他们的标准操作程序(SOP)如下: 一旦一组中有一个可能的患者, 组内的所有成员就都是可能的患者…
Description 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 t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1829 题意:就是给你m条关系a与b有性关系,问这些关系中是否有同性恋 这是一道简单的种类并查集,而且也比较简单只要比较给出的两个点是否有相同祖宗如果有那么他们距离祖宗结点的距离是否为偶数 如果是偶数那么他(她)们必然是同性恋. #include <iostream> #include <cstring> #include <cstdio> using namespace s…
HDU1213How Many Tables Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, and all…
A secret service developed a new kind of explosive that attain its volatile property only when a specific association of products occurs. Each product is a mix of two different simple compounds, to which we call a binding pair. If N > 2, then mixing N…
题目地址 http://acm.hdu.edu.cn/showproblem.php?pid=1213 #include<iostream> using namespace std; #define MAX 100005 int fa[MAX]; int findHead(int x) { while(x!=fa[x]) x=fa[x]; return x; } void Union(int x,int y) { int fa_x=findHead(x); int fa_y=findHead(…
思路:给定一个无向图,判断有几个联通块. AC代码 #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <utility> #include <string> #include <iostream> #include <map> #include <set> #include <…