Submission #932624

# Submission time Handle Problem Language Result Execution time Memory
932624 2024-02-24T01:13:47 Z Programmer123 Fountain Parks (IOI21_parks) C++17
5 / 100
216 ms 54624 KB
#include <bits/stdc++.h>
#include "parks.h"

std::unordered_map<int, int> map[200001];
int construct_roads(std::vector<int> x, std::vector<int> y) {
    int N = (int) x.size();
    if (N == 1) {
        build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    for (int i = 0; i < N; ++i) {
        map[x[i]][y[i]] = i;
    }
    bool seen[N];
    for (int i = 0; i < N; ++i) {
        seen[i] = false;
    }
    std::queue<int> bfs;
    bfs.push(0);
    seen[0] = true;
    auto add = [&](int x, int y, std::vector<int> &data) {
        if (x < 0 || x > 200000) return;
        if (map[x].count(y)) data.push_back(map[x][y]);
    };
    auto edges = [&](int x, int y) {
        std::vector<int> result;
        add(x, y + 2, result);
        add(x, y - 2, result);
        add(x + 2, y, result);
        add(x - 2, y, result);
        return result;
    };
    int rem = N - 1;
    while (!bfs.empty()) {
        auto next = bfs.front();
        bfs.pop();
        for (auto n: edges(x[next], y[next])) {
            if (!seen[n]) {
                seen[n] = true;
                bfs.push(n);
                rem--;
                u.push_back(next);
                v.push_back(n);
            }
        }
    }
    if (rem)
        return 0;

    std::function<std::vector<std::pair<int, int>>(int, int)> valid = [&x, &y](int u,
                                                                               int v) -> std::vector<std::pair<int, int>> {
        if (x[u] == x[v]) {
            int _y = (y[u] + y[v]) / 2;
            return {{x[u] + 1, _y},
                    {x[u] - 1, _y}};
        } else {
            int _x = (x[u] + x[v]) / 2;
            return {{_x, y[u] + 1}, {_x, y[u] - 1}};
        }
    };
    std::vector<std::pair<int, int>> vld[N - 1];
    for (int i = 0; i < N - 1; ++i) {
        vld[i] = valid(u[i], v[i]);
        a.push_back(vld[i][0].first);
        b.push_back(vld[i][0].second);
    }
    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
17 Correct 3 ms 11356 KB Output is correct
18 Correct 3 ms 11356 KB Output is correct
19 Correct 3 ms 11356 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11356 KB Output is correct
22 Incorrect 3 ms 11400 KB Tree @(3, 199999) appears more than once: for edges on positions 0 and 2
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
17 Correct 3 ms 11356 KB Output is correct
18 Correct 3 ms 11356 KB Output is correct
19 Correct 3 ms 11356 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11356 KB Output is correct
22 Incorrect 3 ms 11400 KB Tree @(3, 199999) appears more than once: for edges on positions 0 and 2
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
17 Correct 3 ms 11356 KB Output is correct
18 Correct 4 ms 11356 KB Output is correct
19 Correct 3 ms 11356 KB Output is correct
20 Incorrect 216 ms 54624 KB Tree @(195233, 4771) appears more than once: for edges on positions 0 and 2
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
17 Incorrect 187 ms 50044 KB Tree @(3, 3) appears more than once: for edges on positions 182419 and 182421
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11356 KB Output is correct
2 Correct 3 ms 11356 KB Output is correct
3 Correct 3 ms 11352 KB Output is correct
4 Correct 3 ms 11396 KB Output is correct
5 Correct 3 ms 11352 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Correct 3 ms 11356 KB Output is correct
8 Correct 3 ms 11356 KB Output is correct
9 Correct 68 ms 29692 KB Output is correct
10 Correct 9 ms 13144 KB Output is correct
11 Correct 33 ms 21176 KB Output is correct
12 Correct 12 ms 14168 KB Output is correct
13 Correct 14 ms 14776 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 4 ms 11356 KB Output is correct
16 Correct 71 ms 29792 KB Output is correct
17 Correct 3 ms 11356 KB Output is correct
18 Correct 3 ms 11356 KB Output is correct
19 Correct 3 ms 11356 KB Output is correct
20 Correct 3 ms 11356 KB Output is correct
21 Correct 3 ms 11356 KB Output is correct
22 Incorrect 3 ms 11400 KB Tree @(3, 199999) appears more than once: for edges on positions 0 and 2
23 Halted 0 ms 0 KB -