hiho week 309 register

Ended

Participants:37

Verdict:Accepted
Score:100 / 100
Submitted:2020-06-06 11:18:33

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 <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define LL long long
const int MAXN = 100000+5;
int N;
int A[MAXN];
vector<int> cost(MAXN, 0);
vector<vector<int>> g(MAXN);
int f[MAXN] = {0};
int Find(int x)
{
    if (x == f[x]) return x;
    return f[x]=Find(f[x]);
}
void Union(int x, int y)
{
    int fx = Find(x);
    int fy = Find(y);
    if (fx!=fy) {
        f[fy] = fx;
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX