A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13709 Accepted Submission(s): 4449 Problem Description Background Professor Hopper is researching the sexual behavior of a rare…
Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-lines. The mayor of D-city wants…
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=45522 给定一棵树的n个节点,每个节点标号在1到n之间,1是树的根节点,有如下两种操作: M v :把编号为v的节点标记. Q v :查询与v节点距离最近的被标记的点的编号.最初只有根节点被标记. 输入n-1个数表示,每一个数是当前第i个数的父节点,输出对于每个查询得到标号的总和. 并查集与树的结合,在输入的时候就可以根据父节点的关系建立并查集,1的父亲是1. 还有把编号为…
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. The computers are repaired…
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely, he re…
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…
#include <iostream> #include <algorithm> using namespace std; + ; int fa[maxn]; int Find(int x){ if (x == fa[x]) return x; else return fa[x] = Find(fa[x]); } int main(){ int a, b; while (cin >> a){ //init ; i < maxn; i++) fa[i] = i; ;…