Building Block[HDU2818]】的更多相关文章

Building Block Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5426 Accepted Submission(s): 1663 Problem DescriptionJohn are playing with blocks. There are N blocks (1 <= N <= 30000) numbered 1...…
Building Block Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3250    Accepted Submission(s): 973 Problem Description John are playing with blocks. There are N blocks (1 <= N <= 30000) numbere…
Building Block Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 156 Accepted Submission(s): 70   Problem Description John are playing with blocks. There are N blocks (1 <= N <= 30000) numbered 1..…
Building Block Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5811    Accepted Submission(s): 1790 Problem Description John are playing with blocks. There are N blocks (1 <= N <= 30000) number…
Problem Description John are playing with blocks. There are N blocks (1 <= N <= 30000) numbered 1...N.Initially, there are N piles, and each pile contains one block. Then John do some operations P times (1 <= P <= 1000000). There are two kinds…
Problem Description John are playing with blocks. There are N blocks ( <= N <= ) numbered ...N.Initially, there are N piles, and each pile contains one block. Then John <= P <= ). There are two kinds of operation: M X Y : Put the whole pile co…
http://acm.hdu.edu.cn/showproblem.php?pid=2818 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5935    Accepted Submission(s): 1838 Problem Description John are playing with blocks. There are N…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2818 题意:有N个块,每次有两个操作: M x y表示把x所在的那一堆全部移到y所在的那一堆的下方. C x 询问在x下方有多少个方块. 用并查集,在路径压缩的时候后序更新当前块下有多少个其他块,注意这里“当前块下”其实和并查集是相反的,也就是父亲节点在儿子下面. 需要额外维护一个量:某一堆的块的总数,这个在unite操作的时候,如果不是同一个根,直接将一部分加到另一部分上就可以. /* ━━━━━…
题意: 一共有30000个箱子,刚开始时都是分开放置的.接下来会有两种操作: 1. M x y,表示把x箱子所在的一摞放到y箱子那一摞上. 2. C y,表示询问y下方有多少个箱子. 输入: 首行输入一个整数m,表示一共有m次操作. 接下来每次操作都是上面所说的两种中的一种. 输出: 每次C y,输出一个结果,每次输出占1行. 就是不知道究竟是只有一组测试样例还是有多组测试样例,不过我还是按照多组的方式写了. 题解: 这道题我自己思考了好久都没有思路,最后中忍不住去看了题解,然后被题解震惊了.…
在进行并的时候不能瞎jb并,比如(x, y)就必须把x并给y ,即fa[x] = y #include <iostream> #include <string> #include <cstring> #include <algorithm> using namespace std; + ; int a[maxn]; int fa[maxn]; int Rank[maxn]; int cnt[maxn]; //种类 int Find(int x){ if (x…