답안 #796307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796307 2023-07-28T09:06:45 Z t6twotwo 분수 공원 (IOI21_parks) C++17
15 / 100
125 ms 24408 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct dsu {
    int n;
    vector<int> p, s;
    dsu(int n) : n(n), p(n), s(n, 1) {
        iota(p.begin(), p.end(), 0);
    }
    int find(int x) {
        return x == p[x] ? x : p[x] = find(p[x]);
    }
    int size(int x) {
        return s[find(x)];
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return 0;
        }
        if (s[x] > s[y]) {
            swap(x, y);
        }
        p[x] = y;
        s[y] += s[x];
        return 1;
    }
};
int construct_roads(vector<int> X, vector<int> Y) {
    int N = X.size();
    vector f(5, vector(200003, -1));
    for (int i = 0; i < N; i++) {
        f[X[i]][Y[i]] = i;
    }
    dsu uf(N);
    vector<int> u, v, a, b;
    for (int y = 2; y <= 200000; y += 2) {
        for (int x = 2; x <= 4; x += 2) {
            if (f[x][y] != -1 && f[x][y + 2] != -1) {
                u.push_back(f[x][y]);
                v.push_back(f[x][y + 2]);
                a.push_back(2 * x - 3);
                b.push_back(y + 1);
                uf.unite(f[x][y], f[x][y + 2]);
            }
        }
        if (f[2][y] != -1 && f[4][y] != -1) {
            u.push_back(f[2][y]);
            v.push_back(f[4][y]);
            a.push_back(3);
            b.push_back(y - 1);
            uf.unite(f[2][y], f[4][y]);
        }
    }
    if (uf.size(0) != N) {
        return 0;
    }
    build(u, v, a, b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 116 ms 23096 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5076 KB Output is correct
27 Correct 3 ms 5048 KB Output is correct
28 Correct 45 ms 12480 KB Output is correct
29 Correct 66 ms 16864 KB Output is correct
30 Correct 88 ms 20572 KB Output is correct
31 Correct 125 ms 24408 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 2 ms 4904 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4948 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 2 ms 4948 KB Output is correct
42 Correct 2 ms 4908 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 5076 KB Output is correct
45 Correct 47 ms 12240 KB Output is correct
46 Correct 61 ms 16348 KB Output is correct
47 Correct 60 ms 16344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 116 ms 23096 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5076 KB Output is correct
27 Correct 3 ms 5048 KB Output is correct
28 Correct 45 ms 12480 KB Output is correct
29 Correct 66 ms 16864 KB Output is correct
30 Correct 88 ms 20572 KB Output is correct
31 Correct 125 ms 24408 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 2 ms 4904 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4948 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 2 ms 4948 KB Output is correct
42 Correct 2 ms 4908 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 5076 KB Output is correct
45 Correct 47 ms 12240 KB Output is correct
46 Correct 61 ms 16348 KB Output is correct
47 Correct 60 ms 16344 KB Output is correct
48 Runtime error 7 ms 8364 KB Execution killed with signal 6
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
17 Runtime error 5 ms 8388 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
17 Runtime error 33 ms 14660 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4984 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 42 ms 11572 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 22 ms 8168 KB Output is correct
12 Correct 8 ms 5316 KB Output is correct
13 Correct 8 ms 6468 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 42 ms 11588 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 116 ms 23096 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5076 KB Output is correct
27 Correct 3 ms 5048 KB Output is correct
28 Correct 45 ms 12480 KB Output is correct
29 Correct 66 ms 16864 KB Output is correct
30 Correct 88 ms 20572 KB Output is correct
31 Correct 125 ms 24408 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 2 ms 4904 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4948 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 2 ms 4948 KB Output is correct
42 Correct 2 ms 4908 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 5076 KB Output is correct
45 Correct 47 ms 12240 KB Output is correct
46 Correct 61 ms 16348 KB Output is correct
47 Correct 60 ms 16344 KB Output is correct
48 Runtime error 7 ms 8364 KB Execution killed with signal 6
49 Halted 0 ms 0 KB -