Submission #796297

# Submission time Handle Problem Language Result Execution time Memory
796297 2023-07-28T09:00:32 Z t6twotwo Fountain Parks (IOI21_parks) C++17
5 / 100
44 ms 15916 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++) {
        for (int x = 2; x <= 4; x++) {
            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);
        }
    }
    if (uf.size(0) != N) {
        return 0;
    }
    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
17 Incorrect 3 ms 4948 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
17 Incorrect 3 ms 4948 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
17 Runtime error 5 ms 8376 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
17 Runtime error 35 ms 15916 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4908 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 44 ms 12228 KB Output is correct
10 Correct 7 ms 5184 KB Output is correct
11 Correct 23 ms 8516 KB Output is correct
12 Correct 9 ms 5416 KB Output is correct
13 Correct 9 ms 6892 KB Output is correct
14 Correct 3 ms 5040 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 42 ms 12208 KB Output is correct
17 Incorrect 3 ms 4948 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -