hiho week 14 register

Ended

Participants:423

Verdict:Accepted
Score:100 / 100
Submitted:2014-10-08 09:58:40

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <map>
#include <string>
using namespace std;
#define MAXN 100010
map<string, int> name2id;
int p[MAXN], Rank[MAXN];
void make_set(int u)
{
    p[u] = u;
    Rank[u] = 0;
}
int find_set(int u)
{
    if (p[u] != u)
        p[u] = find_set(p[u]);
    return p[u];
}
void union_set(int x, int y)
{
    x = find_set(x);
    y = find_set(y);
    if (Rank[x] > Rank[y])
        p[y] = x;
    else if (Rank[y] > Rank[x])
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX