Submission #831859

# Submission time Handle Problem Language Result Execution time Memory
831859 2023-08-20T16:15:29 Z andrey27_sm Fountain Parks (IOI21_parks) C++17
45 / 100
456 ms 40540 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> cons[200001];
int mask_l[200001];
vector<int> u;
vector<int> v;
vector<int> a;
vector<int> b;
struct dsu{
    int sz = 0;
    vector<int> pr;
    int p(int v){
        if(pr[v] == v) return v;
        return pr[v] = p(pr[v]);
    }
    bool un(int u,int v){
        u = p(u);
        v = p(v);
        if(u == v){
            return 0;
            exit(1);
        }
        pr[u] = v;
        sz++;
        return 1;
    }
} D;
int construct_roads(vector<int> x, vector<int> y) {
    int n = x.size();
    D.pr.resize(n);
    map<pair<int,int>,int> sol;
    for (int i = 0; i < n; ++i)
    {
        D.pr[i] = i;
    }
    vector<pair<int,pair<int,int>>> x_d;
    vector<pair<int,pair<int,int>>> y_d;
    for (int i = 0; i < n; ++i)
    {
        x_d.push_back({x[i],{y[i],i}});
        y_d.push_back({y[i],{x[i],i}});
        sol[{x[i],y[i]}] = i;
    }
    sort(x_d.begin(), x_d.end());
    sort(y_d.begin(), y_d.end());
    for (int i = 1; i < n; ++i)
    {
        if(x_d[i].first == x_d[i-1].first and x_d[i].second.first-2 == x_d[i-1].second.first){
            D.un(x_d[i-1].second.second,x_d[i].second.second);
        }
    }
    for (int i = 1; i < n; ++i)
    {
        if(y_d[i].first == y_d[i-1].first and y_d[i].second.first-2 == y_d[i-1].second.first){
            D.un(y_d[i-1].second.second,y_d[i].second.second);
        }
    }
    if(D.sz != n-1) return 0;
    for (int i = 0; i < n; ++i)
    {
        if(sol.count({x[i],y[i]+2})){
            u.push_back(sol[{x[i],y[i]+2}]);
            v.push_back(i);
            if((x[i]+y[i])&3) a.push_back(x[i]+1);
            else a.push_back(x[i]-1);
            b.push_back(y[i]+1);
        }

        if(sol.count({x[i]+2,y[i]})){
            u.push_back(sol[{x[i]+2,y[i]}]);
            v.push_back(i);
            if((x[i]+y[i])&3) b.push_back(y[i]-1);
            else b.push_back(y[i]+1);
            a.push_back(x[i]+1);
        }
    }
    //if(points.size() != n-1) return 0;
    build(u,v,a,b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
17 Incorrect 2 ms 4948 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 3
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
17 Incorrect 2 ms 4948 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 3
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 3 ms 5000 KB Output is correct
19 Correct 2 ms 5000 KB Output is correct
20 Correct 388 ms 38700 KB Output is correct
21 Correct 412 ms 38504 KB Output is correct
22 Correct 368 ms 38640 KB Output is correct
23 Correct 262 ms 34024 KB Output is correct
24 Correct 191 ms 27820 KB Output is correct
25 Correct 156 ms 27696 KB Output is correct
26 Correct 165 ms 27752 KB Output is correct
27 Correct 377 ms 37852 KB Output is correct
28 Correct 377 ms 37804 KB Output is correct
29 Correct 402 ms 38032 KB Output is correct
30 Correct 417 ms 37876 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 19 ms 7356 KB Output is correct
33 Correct 64 ms 16748 KB Output is correct
34 Correct 347 ms 38788 KB Output is correct
35 Correct 8 ms 6228 KB Output is correct
36 Correct 34 ms 10820 KB Output is correct
37 Correct 71 ms 16740 KB Output is correct
38 Correct 132 ms 18888 KB Output is correct
39 Correct 173 ms 23684 KB Output is correct
40 Correct 226 ms 29540 KB Output is correct
41 Correct 296 ms 34196 KB Output is correct
42 Correct 392 ms 39192 KB Output is correct
43 Correct 2 ms 4948 KB Output is correct
44 Correct 2 ms 5004 KB Output is correct
45 Correct 2 ms 4948 KB Output is correct
46 Correct 3 ms 4948 KB Output is correct
47 Correct 2 ms 4948 KB Output is correct
48 Correct 2 ms 5004 KB Output is correct
49 Correct 3 ms 4948 KB Output is correct
50 Correct 3 ms 5000 KB Output is correct
51 Correct 2 ms 4948 KB Output is correct
52 Correct 3 ms 5004 KB Output is correct
53 Correct 2 ms 5008 KB Output is correct
54 Correct 5 ms 5204 KB Output is correct
55 Correct 4 ms 5328 KB Output is correct
56 Correct 138 ms 21664 KB Output is correct
57 Correct 271 ms 29360 KB Output is correct
58 Correct 257 ms 29564 KB Output is correct
59 Correct 3 ms 4948 KB Output is correct
60 Correct 3 ms 4948 KB Output is correct
61 Correct 3 ms 4948 KB Output is correct
62 Correct 308 ms 37888 KB Output is correct
63 Correct 350 ms 39180 KB Output is correct
64 Correct 372 ms 38380 KB Output is correct
65 Correct 4 ms 5400 KB Output is correct
66 Correct 8 ms 5844 KB Output is correct
67 Correct 172 ms 21428 KB Output is correct
68 Correct 236 ms 30456 KB Output is correct
69 Correct 445 ms 37892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
17 Correct 397 ms 38852 KB Output is correct
18 Correct 386 ms 39204 KB Output is correct
19 Correct 408 ms 38564 KB Output is correct
20 Correct 391 ms 40540 KB Output is correct
21 Correct 364 ms 34900 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 46 ms 10724 KB Output is correct
24 Correct 15 ms 7312 KB Output is correct
25 Correct 50 ms 13584 KB Output is correct
26 Correct 87 ms 19060 KB Output is correct
27 Correct 187 ms 22972 KB Output is correct
28 Correct 216 ms 27816 KB Output is correct
29 Correct 308 ms 32392 KB Output is correct
30 Correct 347 ms 35908 KB Output is correct
31 Correct 456 ms 40188 KB Output is correct
32 Correct 352 ms 40304 KB Output is correct
33 Correct 315 ms 39196 KB Output is correct
34 Correct 5 ms 5588 KB Output is correct
35 Correct 8 ms 6100 KB Output is correct
36 Correct 140 ms 21724 KB Output is correct
37 Correct 251 ms 30356 KB Output is correct
38 Correct 332 ms 38704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 5000 KB Output is correct
7 Correct 2 ms 5008 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 123 ms 21372 KB Output is correct
10 Correct 10 ms 6632 KB Output is correct
11 Correct 49 ms 13756 KB Output is correct
12 Correct 14 ms 7380 KB Output is correct
13 Correct 18 ms 10064 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 125 ms 21388 KB Output is correct
17 Incorrect 2 ms 4948 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 3
18 Halted 0 ms 0 KB -