Submission #623459

# Submission time Handle Problem Language Result Execution time Memory
623459 2022-08-05T15:55:56 Z cheissmart Fountain Parks (IOI21_parks) C++17
15 / 100
466 ms 78228 KB
#include "parks.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int dx[] = {0, 0, 2, -2}, dy[] = {2, -2, 0, 0};

int construct_roads(vi x, vi y) {
    int n = SZ(x);
    map<pi, int> mp;
    for(int i = 0; i < n; i++)
        mp[{x[i], y[i]}] = i;

    V<pi> edges;
    set<pi> vis;
    function<void(int, int)> dfs = [&] (int X, int Y) {
        vis.insert({X, Y});
        for(int i = 0; i < 4; i++) {
            int xx = X + dx[i], yy = Y + dy[i];
            if(mp.count({xx, yy}) && !vis.count({xx, yy})) {
                edges.EB(mp[{X, Y}], mp[{xx, yy}]);
                dfs(xx, yy);
            }
        }
    };
    dfs(x[0], y[0]);
    if(SZ(vis) != n) return 0;

    vi u, v, a, b;
    for(int i = 0; i < n - 1; i++) {
        u.PB(edges[i].F), v.PB(edges[i].S);
        int X = (x[edges[i].F] + x[edges[i].S]) / 2;
        int Y = (y[edges[i].F] + y[edges[i].S]) / 2;
        if(x[edges[i].F] == x[edges[i].S]) { // vertical
            if(X == 2) X--;
            else X++;
        } else { // horizontal
            Y--;
        }
        a.PB(X), b.PB(Y);
    }
    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 466 ms 77408 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 150 ms 31372 KB Output is correct
29 Correct 239 ms 46224 KB Output is correct
30 Correct 348 ms 62516 KB Output is correct
31 Correct 459 ms 77384 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 300 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 172 ms 31616 KB Output is correct
46 Correct 270 ms 47728 KB Output is correct
47 Correct 284 ms 46460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 466 ms 77408 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 150 ms 31372 KB Output is correct
29 Correct 239 ms 46224 KB Output is correct
30 Correct 348 ms 62516 KB Output is correct
31 Correct 459 ms 77384 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 300 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 172 ms 31616 KB Output is correct
46 Correct 270 ms 47728 KB Output is correct
47 Correct 284 ms 46460 KB Output is correct
48 Incorrect 0 ms 212 KB Tree @(5, 3) appears more than once: for edges on positions 1 and 2
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 463 ms 78228 KB Output is correct
21 Incorrect 438 ms 70672 KB Tree @(56857, 56861) appears more than once: for edges on positions 1 and 2
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
17 Correct 461 ms 78120 KB Output is correct
18 Incorrect 432 ms 63320 KB Tree @(50003, 100001) appears more than once: for edges on positions 44663 and 44664
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 174 ms 37156 KB Output is correct
10 Correct 14 ms 4228 KB Output is correct
11 Correct 92 ms 20804 KB Output is correct
12 Correct 27 ms 5988 KB Output is correct
13 Correct 47 ms 11456 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 171 ms 29564 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 466 ms 77408 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 150 ms 31372 KB Output is correct
29 Correct 239 ms 46224 KB Output is correct
30 Correct 348 ms 62516 KB Output is correct
31 Correct 459 ms 77384 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 300 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 172 ms 31616 KB Output is correct
46 Correct 270 ms 47728 KB Output is correct
47 Correct 284 ms 46460 KB Output is correct
48 Incorrect 0 ms 212 KB Tree @(5, 3) appears more than once: for edges on positions 1 and 2
49 Halted 0 ms 0 KB -