Submission #435539

# Submission time Handle Problem Language Result Execution time Memory
435539 2021-06-23T12:11:05 Z Ozy Fountain Parks (IOI21_parks) C++17
15 / 100
1578 ms 84124 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 200000
#define fil first
#define col second

int n,num;
vector<int> u,v,a,b;
set<pair<int,int> > existe;
map<pair<int,int>,int> id;
map<int,pair<int,int> > val;
vector< int > hijos[MAX+2];
int visitados[MAX+2],ori[8] {2,0,-2,0,0,2,0,-2};

void DFS(int pos) {

    visitados[pos] = 1;
    num++;
    existe.erase(val[pos]);

    for (auto h : hijos[pos]) {
        pair<int,int> p = val[pos];
        pair<int,int> q = val[h];
        if (existe.find(q) == existe.end()) continue;

        if (p.fil == q.fil){
            u.push_back(pos);
            v.push_back(h);
            a.push_back(min(p.col,q.col)+1); //columna
            b.push_back(p.fil-1);
        }
        else {
            u.push_back(pos);
            v.push_back(h);
            b.push_back(min(p.fil, q.fil)+1);
            if (p.col == 2) a.push_back(1);
            else a.push_back(5);
        }
    }

    for (auto h : hijos[pos]) if (visitados[h] == 0) DFS(h);

}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
        build({}, {}, {}, {});
        return 1;
    }

    n = x.size();
    rep(i,0,n) {
        existe.insert({y[i], x[i]});
        id[{y[i], x[i]}] = i;
        val[i] = {y[i], x[i]};

        rep(j,0,3) {
            if (existe.find({y[i]+ori[j], x[i]+ori[j+4]}) != existe.end()) {
                hijos[i].push_back(id[{y[i]+ori[j], x[i]+ori[j+4]}]);
                hijos[id[{y[i]+ori[j], x[i]+ori[j+4]}]].push_back(i);
            }
        }
    }

    DFS(0);
    if (num < n) return 0;

    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 1515 ms 80016 KB Output is correct
24 Correct 3 ms 4940 KB Output is correct
25 Correct 7 ms 5464 KB Output is correct
26 Correct 11 ms 5780 KB Output is correct
27 Correct 14 ms 5852 KB Output is correct
28 Correct 506 ms 35656 KB Output is correct
29 Correct 881 ms 48056 KB Output is correct
30 Correct 1177 ms 64516 KB Output is correct
31 Correct 1578 ms 78228 KB Output is correct
32 Correct 3 ms 4940 KB Output is correct
33 Correct 5 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 5 ms 4940 KB Output is correct
38 Correct 4 ms 4904 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 10 ms 5452 KB Output is correct
44 Correct 9 ms 5636 KB Output is correct
45 Correct 538 ms 39864 KB Output is correct
46 Correct 881 ms 56572 KB Output is correct
47 Correct 905 ms 55628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 1515 ms 80016 KB Output is correct
24 Correct 3 ms 4940 KB Output is correct
25 Correct 7 ms 5464 KB Output is correct
26 Correct 11 ms 5780 KB Output is correct
27 Correct 14 ms 5852 KB Output is correct
28 Correct 506 ms 35656 KB Output is correct
29 Correct 881 ms 48056 KB Output is correct
30 Correct 1177 ms 64516 KB Output is correct
31 Correct 1578 ms 78228 KB Output is correct
32 Correct 3 ms 4940 KB Output is correct
33 Correct 5 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 5 ms 4940 KB Output is correct
38 Correct 4 ms 4904 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 10 ms 5452 KB Output is correct
44 Correct 9 ms 5636 KB Output is correct
45 Correct 538 ms 39864 KB Output is correct
46 Correct 881 ms 56572 KB Output is correct
47 Correct 905 ms 55628 KB Output is correct
48 Incorrect 4 ms 4940 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 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
17 Incorrect 3 ms 4940 KB Tree (a[0], b[0]) = (5, 3) is not adjacent to edge between u[0]=0 @(200000, 2) and v[0]=1 @(200000, 4)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
17 Incorrect 1302 ms 84124 KB Tree (a[141211], b[141211]) = (5, 3) is not adjacent to edge between u[141211]=138413 @(100002, 2) and v[141211]=87394 @(100002, 4)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
9 Correct 605 ms 43612 KB Output is correct
10 Correct 25 ms 9096 KB Output is correct
11 Correct 149 ms 26380 KB Output is correct
12 Correct 37 ms 11152 KB Output is correct
13 Correct 98 ms 19376 KB Output is correct
14 Correct 5 ms 5196 KB Output is correct
15 Correct 9 ms 5520 KB Output is correct
16 Correct 583 ms 38480 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 1515 ms 80016 KB Output is correct
24 Correct 3 ms 4940 KB Output is correct
25 Correct 7 ms 5464 KB Output is correct
26 Correct 11 ms 5780 KB Output is correct
27 Correct 14 ms 5852 KB Output is correct
28 Correct 506 ms 35656 KB Output is correct
29 Correct 881 ms 48056 KB Output is correct
30 Correct 1177 ms 64516 KB Output is correct
31 Correct 1578 ms 78228 KB Output is correct
32 Correct 3 ms 4940 KB Output is correct
33 Correct 5 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 5 ms 4940 KB Output is correct
38 Correct 4 ms 4904 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 10 ms 5452 KB Output is correct
44 Correct 9 ms 5636 KB Output is correct
45 Correct 538 ms 39864 KB Output is correct
46 Correct 881 ms 56572 KB Output is correct
47 Correct 905 ms 55628 KB Output is correct
48 Incorrect 4 ms 4940 KB Tree @(5, 3) appears more than once: for edges on positions 1 and 2
49 Halted 0 ms 0 KB -