hiho week 183 register

Ended

Participants:162

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-30 21:23:37

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 <bits/stdc++.h>
using namespace std;
int fa[1010 * 1010];
int rk[1010 * 1010];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool a[1010][1010];
int findfa(int x) {
    return x == fa[x] ? x : fa[x] = findfa(fa[x]);
}
void Union(int u, int v) {
    int x = findfa(u), y = findfa(v);
    if (x != y) {
        if (rk[x] < rk[y]) fa[x] = y, rk[y] += rk[x];
        else fa[y] = x, rk[x] += rk[y];
    }
}
int main(void) {
    ios::sync_with_stdio(false);
    for (int i = 0; i < 1000 * 1000; ++ i) fa[i] = i, rk[i] = 1;
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++ i) {
        int x, y;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX