답안 #819889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819889 2023-08-10T14:58:50 Z HorizonWest 분수 공원 (IOI21_parks) C++17
15 / 100
157 ms 39460 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

const int Max = 2e5 + 7, Inf = 1e9 + 7;

void build(vector<int> u, vector<int> v, vector<int> a, vector<int> b);

struct DSU
{
    vector <int> link, size;

    int find(int x)
    {
        while(x != link[x]) x = link[x];
        return x;
    }

    bool unite(int a, int b)
    {
        a = find(a); b = find(b);
        if(a == b) return false;
        if(size[a] < size[b]) swap(a, b);
        link[b] = a; size[a] += size[b];
        return true;
    }

    DSU(int n)
    {
        link.assign(n + 1, 1);
        size.assign(n + 1, 1);
        for(int i = 0; i <= n; i++)
            link[i] = i;
    }
};

int construct_roads(vector<int> x, vector<int> y)
{
    vector <vector<int>> g(Max + 1, vector <int> (4, 0));

    int n = (int) x.size();

    for(int i = 0; i < n; i++)
        g[y[i]][x[i]/2] = i + 1;

    vector <int> u, v, a, b; map <int, map <int, bool>> mp;

    DSU St(n);

    for(int i = 0; i < Max; i++)
    {
        if(g[i][1] != 0 && g[i][2] != 0)
        {
            u.pb(g[i][1]); v.pb(g[i][2]);
            a.pb(i-1); b.pb(3); mp[i-1][3] = 1;
            St.unite(g[i][1], g[i][2]);
        }

        if(g[i][2] != 0 && g[i][3] != 0)
        {
            u.pb(g[i][2]); v.pb(g[i][3]);
            a.pb(i+1); b.pb(5); mp[i+1][5] = 1;
            St.unite(g[i][2], g[i][3]);
        }
    }

    for(int i = 0; i < Max; i++)
    {
        if(g[i][1] != 0 && g[i-2][1] != 0)
        {
            if(St.unite(g[i][1], g[i-2][1]))
            {
                u.pb(g[i][1]); v.pb(g[i-2][1]);
                a.pb(i-1); b.pb(1);
            }
        }

        if(g[i][3] != 0 && g[i-2][3] != 0)
        {
            if(St.unite(g[i][3], g[i-2][3]))
            {
                u.pb(g[i][3]); v.pb(g[i-2][3]);
                a.pb(i-1); b.pb(7);
            }
        }

        if(g[i][2] != 0 && g[i-2][2] != 0)
        {
            if(St.unite(g[i][2], g[i-2][2]))
            {
                u.pb(g[i][2]); v.pb(g[i-2][2]);
                a.pb(i-1);
                if(!mp[i-1][5]) b.pb(5);
                else b.pb(3);
            }
        }
    }

    if(St.size[St.find(1)] != n)return 0;
    else
    {
        for(int i = 0; i < (int) u.size(); i++)
            u[i]--, v[i]--;
        build(u, v, b, a);
        return 1;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
17 Correct 13 ms 11220 KB Output is correct
18 Correct 12 ms 11220 KB Output is correct
19 Correct 13 ms 11208 KB Output is correct
20 Correct 12 ms 11192 KB Output is correct
21 Correct 12 ms 11188 KB Output is correct
22 Correct 12 ms 11220 KB Output is correct
23 Correct 157 ms 39460 KB Output is correct
24 Correct 12 ms 11220 KB Output is correct
25 Correct 13 ms 11436 KB Output is correct
26 Correct 16 ms 11604 KB Output is correct
27 Correct 13 ms 11604 KB Output is correct
28 Correct 55 ms 22476 KB Output is correct
29 Correct 80 ms 28148 KB Output is correct
30 Correct 106 ms 33768 KB Output is correct
31 Correct 126 ms 39432 KB Output is correct
32 Correct 12 ms 11220 KB Output is correct
33 Correct 13 ms 11220 KB Output is correct
34 Correct 12 ms 11172 KB Output is correct
35 Correct 12 ms 11240 KB Output is correct
36 Correct 12 ms 11220 KB Output is correct
37 Correct 12 ms 11220 KB Output is correct
38 Correct 12 ms 11220 KB Output is correct
39 Correct 12 ms 11220 KB Output is correct
40 Correct 12 ms 11180 KB Output is correct
41 Correct 13 ms 11220 KB Output is correct
42 Correct 12 ms 11220 KB Output is correct
43 Correct 15 ms 11476 KB Output is correct
44 Correct 13 ms 11512 KB Output is correct
45 Correct 81 ms 25996 KB Output is correct
46 Correct 96 ms 32800 KB Output is correct
47 Correct 98 ms 32740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
17 Correct 13 ms 11220 KB Output is correct
18 Correct 12 ms 11220 KB Output is correct
19 Correct 13 ms 11208 KB Output is correct
20 Correct 12 ms 11192 KB Output is correct
21 Correct 12 ms 11188 KB Output is correct
22 Correct 12 ms 11220 KB Output is correct
23 Correct 157 ms 39460 KB Output is correct
24 Correct 12 ms 11220 KB Output is correct
25 Correct 13 ms 11436 KB Output is correct
26 Correct 16 ms 11604 KB Output is correct
27 Correct 13 ms 11604 KB Output is correct
28 Correct 55 ms 22476 KB Output is correct
29 Correct 80 ms 28148 KB Output is correct
30 Correct 106 ms 33768 KB Output is correct
31 Correct 126 ms 39432 KB Output is correct
32 Correct 12 ms 11220 KB Output is correct
33 Correct 13 ms 11220 KB Output is correct
34 Correct 12 ms 11172 KB Output is correct
35 Correct 12 ms 11240 KB Output is correct
36 Correct 12 ms 11220 KB Output is correct
37 Correct 12 ms 11220 KB Output is correct
38 Correct 12 ms 11220 KB Output is correct
39 Correct 12 ms 11220 KB Output is correct
40 Correct 12 ms 11180 KB Output is correct
41 Correct 13 ms 11220 KB Output is correct
42 Correct 12 ms 11220 KB Output is correct
43 Correct 15 ms 11476 KB Output is correct
44 Correct 13 ms 11512 KB Output is correct
45 Correct 81 ms 25996 KB Output is correct
46 Correct 96 ms 32800 KB Output is correct
47 Correct 98 ms 32740 KB Output is correct
48 Correct 12 ms 11220 KB Output is correct
49 Correct 14 ms 11220 KB Output is correct
50 Correct 12 ms 11160 KB Output is correct
51 Correct 15 ms 11240 KB Output is correct
52 Correct 12 ms 11220 KB Output is correct
53 Correct 12 ms 11220 KB Output is correct
54 Incorrect 12 ms 11140 KB Tree @(3, 5) appears more than once: for edges on positions 2 and 5
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
17 Runtime error 18 ms 22612 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
17 Runtime error 63 ms 36752 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11220 KB Output is correct
2 Correct 12 ms 11188 KB Output is correct
3 Correct 12 ms 11220 KB Output is correct
4 Correct 12 ms 11220 KB Output is correct
5 Correct 12 ms 11220 KB Output is correct
6 Correct 12 ms 11132 KB Output is correct
7 Correct 12 ms 11240 KB Output is correct
8 Correct 12 ms 11220 KB Output is correct
9 Correct 54 ms 18444 KB Output is correct
10 Correct 16 ms 11988 KB Output is correct
11 Correct 35 ms 15180 KB Output is correct
12 Correct 18 ms 12244 KB Output is correct
13 Correct 19 ms 13164 KB Output is correct
14 Correct 12 ms 11300 KB Output is correct
15 Correct 12 ms 11348 KB Output is correct
16 Correct 54 ms 18424 KB Output is correct
17 Correct 13 ms 11220 KB Output is correct
18 Correct 12 ms 11220 KB Output is correct
19 Correct 13 ms 11208 KB Output is correct
20 Correct 12 ms 11192 KB Output is correct
21 Correct 12 ms 11188 KB Output is correct
22 Correct 12 ms 11220 KB Output is correct
23 Correct 157 ms 39460 KB Output is correct
24 Correct 12 ms 11220 KB Output is correct
25 Correct 13 ms 11436 KB Output is correct
26 Correct 16 ms 11604 KB Output is correct
27 Correct 13 ms 11604 KB Output is correct
28 Correct 55 ms 22476 KB Output is correct
29 Correct 80 ms 28148 KB Output is correct
30 Correct 106 ms 33768 KB Output is correct
31 Correct 126 ms 39432 KB Output is correct
32 Correct 12 ms 11220 KB Output is correct
33 Correct 13 ms 11220 KB Output is correct
34 Correct 12 ms 11172 KB Output is correct
35 Correct 12 ms 11240 KB Output is correct
36 Correct 12 ms 11220 KB Output is correct
37 Correct 12 ms 11220 KB Output is correct
38 Correct 12 ms 11220 KB Output is correct
39 Correct 12 ms 11220 KB Output is correct
40 Correct 12 ms 11180 KB Output is correct
41 Correct 13 ms 11220 KB Output is correct
42 Correct 12 ms 11220 KB Output is correct
43 Correct 15 ms 11476 KB Output is correct
44 Correct 13 ms 11512 KB Output is correct
45 Correct 81 ms 25996 KB Output is correct
46 Correct 96 ms 32800 KB Output is correct
47 Correct 98 ms 32740 KB Output is correct
48 Correct 12 ms 11220 KB Output is correct
49 Correct 14 ms 11220 KB Output is correct
50 Correct 12 ms 11160 KB Output is correct
51 Correct 15 ms 11240 KB Output is correct
52 Correct 12 ms 11220 KB Output is correct
53 Correct 12 ms 11220 KB Output is correct
54 Incorrect 12 ms 11140 KB Tree @(3, 5) appears more than once: for edges on positions 2 and 5
55 Halted 0 ms 0 KB -