답안 #677939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677939 2023-01-04T17:00:20 Z APROHACK 분수 공원 (IOI21_parks) C++17
15 / 100
482 ms 37248 KB
#include "parks.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int N;
vector<pair<int, int > >node;
map<pair<int, int>, int>mp;
vector<int>u, v, a, b;
int padre[200005];

int findPadre(int k){
    if(padre[k] == k)return k;
    return padre[k] = findPadre(padre[k]);
}

void unir(int p, int q){
    p = findPadre(p);
    q = findPadre(q);
    if(p == q){
        return;
    }
    padre[p] = q;
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    N = x.size();
    for(int i = 0 ; i < N ; i ++){
        node.pb({x[i], y[i]});
        mp[{x[i], y[i]}] = i;
        padre[i] = i;
    }

    for(int i = 0 ; i < N ; i++){
        if(node[i].ff == 2 && mp.count({4, node[i].ss})){
            u.pb(i);
            v.pb(mp[{4, node[i].ss}]);
            unir(i, mp[{4, node[i].ss}]);
            a.pb(3);
            b.pb(node[i].ss-1);

        }
        if(mp.count({node[i].ff, node[i].ss-2})){
            if(node[i].ff == 2){
                u.pb(i);
                v.pb(mp[{2, node[i].ss-2}]);
                unir(mp[{2, node[i].ss-2}], i);
                a.pb(1);
                b.pb(node[i].ss-1);
            }else{
                u.pb(i);
                v.pb(mp[{4, node[i].ss-2}]);
                unir(i, mp[{4, node[i].ss-2}]);
                a.pb(5);
                b.pb(node[i].ss-1);
            }
        }
    }
    for(int i =0  ; i < N ; i ++){
        if(findPadre(i) != findPadre(0))return 0;
    }
    build(u, v, a, b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 452 ms 37204 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 4 ms 760 KB Output is correct
28 Correct 133 ms 15660 KB Output is correct
29 Correct 229 ms 22120 KB Output is correct
30 Correct 333 ms 31472 KB Output is correct
31 Correct 482 ms 37248 KB Output is correct
32 Correct 0 ms 308 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 312 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 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 504 KB Output is correct
44 Correct 3 ms 616 KB Output is correct
45 Correct 167 ms 16532 KB Output is correct
46 Correct 253 ms 24636 KB Output is correct
47 Correct 252 ms 24660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 452 ms 37204 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 4 ms 760 KB Output is correct
28 Correct 133 ms 15660 KB Output is correct
29 Correct 229 ms 22120 KB Output is correct
30 Correct 333 ms 31472 KB Output is correct
31 Correct 482 ms 37248 KB Output is correct
32 Correct 0 ms 308 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 312 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 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 504 KB Output is correct
44 Correct 3 ms 616 KB Output is correct
45 Correct 167 ms 16532 KB Output is correct
46 Correct 253 ms 24636 KB Output is correct
47 Correct 252 ms 24660 KB Output is correct
48 Incorrect 1 ms 340 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
17 Incorrect 1 ms 312 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
17 Incorrect 306 ms 25464 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 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 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 143 ms 16348 KB Output is correct
10 Correct 12 ms 2112 KB Output is correct
11 Correct 57 ms 9500 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 34 ms 6340 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 148 ms 16412 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 452 ms 37204 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 456 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 4 ms 760 KB Output is correct
28 Correct 133 ms 15660 KB Output is correct
29 Correct 229 ms 22120 KB Output is correct
30 Correct 333 ms 31472 KB Output is correct
31 Correct 482 ms 37248 KB Output is correct
32 Correct 0 ms 308 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 312 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 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 504 KB Output is correct
44 Correct 3 ms 616 KB Output is correct
45 Correct 167 ms 16532 KB Output is correct
46 Correct 253 ms 24636 KB Output is correct
47 Correct 252 ms 24660 KB Output is correct
48 Incorrect 1 ms 340 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -