Submission #836741

# Submission time Handle Problem Language Result Execution time Memory
836741 2023-08-24T14:46:06 Z FulopMate Fountain Parks (IOI21_parks) C++17
15 / 100
131 ms 23568 KB
#include "parks.h"

#include <bits/stdc++.h>



using namespace std;



struct fountain{

    int x, y, ind;

    bool operator<(fountain&other){

        return make_pair(x, y)<make_pair(other.x, other.y);

    }

};



int construct_roads(vector<int> x, vector<int> y) {

    int n = x.size();

    vector<fountain> v;

    for(int i = 0; i < n; i++){

        v.push_back({y[i], x[i], i}); // FORDITOTT KOORDINATAK!!!!!4!!1!!!14!44!!!

    }

    sort(v.begin(), v.end());

    int el = v[0].x;

    vector<int> ru, rv, ra, rb;

    for(int i = 1; i < n; i++){

        if(v[i-1].x == v[i].x){

            ru.push_back(v[i-1].ind);

            rv.push_back(v[i].ind);

            ra.push_back(v[i].x+1);

            rb.push_back(3);

        } else if(v[i-1].y == v[i].y && v[i].x-v[i-1].x == 2 && v[i-1].x == el){

            ru.push_back(v[i-1].ind);

            rv.push_back(v[i].ind);

            ra.push_back(v[i].x-1);

            rb.push_back(v[i].y == 2 ? 1 : 5);

            el = v[i].x;

        }



        if(i > 1){

            if(v[i-2].x == v[i].x){

                ru.push_back(v[i-2].ind);

                rv.push_back(v[i].ind);

                ra.push_back(v[i].x+1);

                rb.push_back(3);

            } else if(v[i-2].y == v[i].y && v[i].x-v[i-2].x == 2 && v[i-2].x == el){

                ru.push_back(v[i-2].ind);

                rv.push_back(v[i].ind);

                ra.push_back(v[i].x-1);

                rb.push_back(v[i].y == 2 ? 1 : 5);

                el = v[i].x;    

            }

        }

    }



    if(el == v.back().x){

        build(rv, ru, rb, ra);

        return 1;

    } else {

        return 0;

    }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 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 1 ms 212 KB Output is correct
23 Correct 102 ms 17900 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 41 ms 7388 KB Output is correct
29 Correct 59 ms 10512 KB Output is correct
30 Correct 82 ms 14964 KB Output is correct
31 Correct 105 ms 17900 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 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 1 ms 336 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 51 ms 8960 KB Output is correct
46 Correct 74 ms 13764 KB Output is correct
47 Correct 78 ms 13784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 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 1 ms 212 KB Output is correct
23 Correct 102 ms 17900 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 41 ms 7388 KB Output is correct
29 Correct 59 ms 10512 KB Output is correct
30 Correct 82 ms 14964 KB Output is correct
31 Correct 105 ms 17900 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 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 1 ms 336 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 51 ms 8960 KB Output is correct
46 Correct 74 ms 13764 KB Output is correct
47 Correct 78 ms 13784 KB Output is correct
48 Incorrect 1 ms 212 KB Tree (a[0], b[0]) = (3, 3) is not adjacent to edge between u[0]=0 @(6, 2) and v[0]=1 @(4, 2)
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 KB Output is correct
17 Incorrect 1 ms 212 KB Tree (a[0], b[0]) = (3, 3) is not adjacent to edge between u[0]=0 @(200000, 2) and v[0]=2 @(199998, 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 KB Output is correct
17 Incorrect 131 ms 23568 KB Tree (a[1], b[1]) = (3, 3) is not adjacent to edge between u[1]=134526 @(6, 2) and v[1]=22196 @(4, 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 48 ms 8984 KB Output is correct
10 Correct 5 ms 1184 KB Output is correct
11 Correct 22 ms 4816 KB Output is correct
12 Correct 7 ms 1656 KB Output is correct
13 Correct 10 ms 2640 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 48 ms 8968 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 1 ms 212 KB Output is correct
23 Correct 102 ms 17900 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 41 ms 7388 KB Output is correct
29 Correct 59 ms 10512 KB Output is correct
30 Correct 82 ms 14964 KB Output is correct
31 Correct 105 ms 17900 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 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 1 ms 336 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 51 ms 8960 KB Output is correct
46 Correct 74 ms 13764 KB Output is correct
47 Correct 78 ms 13784 KB Output is correct
48 Incorrect 1 ms 212 KB Tree (a[0], b[0]) = (3, 3) is not adjacent to edge between u[0]=0 @(6, 2) and v[0]=1 @(4, 2)
49 Halted 0 ms 0 KB -