Submission #688325

# Submission time Handle Problem Language Result Execution time Memory
688325 2023-01-27T10:07:33 Z coding_snorlax Fountain Parks (IOI21_parks) C++17
15 / 100
175 ms 37228 KB
#include<bits/stdc++.h>
#include "parks.h"
using namespace std;
#define mp make_pair
#define pb push_back
vector<pair<int,int>> G;
vector<pair<int,int>> x_axis[200005];
vector<pair<int,int>> y_axis[200005];
vector<pair<int,int>> choose;
vector<int> u,v,a,b;
int Boss[200005];
int query(int node){
    if(Boss[node]==node) return node;
    return Boss[node]=query(Boss[node]);
}
int Union(int x,int y){
    if(query(x)==query(y)) return 0;
    Boss[query(x)]=query(y);
    return 1;
}
int construct_roads(vector<int> x,vector<int> y){
    for(int i=0;i<200005;i++){
        Boss[i]=i;
    }
    for(int i=0;i<(int)x.size();i++){
        x_axis[x[i]].pb(mp(y[i],i));
        y_axis[y[i]].pb(mp(x[i],i));
    }
    for(int i=0;i<200005;i++){
        sort(x_axis[i].begin(),x_axis[i].end());
        sort(y_axis[i].begin(),y_axis[i].end());
    }
    //construct graph
    for(int i=0;i<200005;i++){
        for(int j=0;j<(int)x_axis[i].size()-1;j++){
            //cout<<x_axis[i][j+1].first<<"\n";
            if(x_axis[i][j+1].first-x_axis[i][j].first==2){
                G.pb(mp(x_axis[i][j+1].second,x_axis[i][j].second));
            }
        }
        for(int j=0;j<(int)y_axis[i].size()-1;j++){
            if(y_axis[i][j+1].first-y_axis[i][j].first==2){
                G.pb(mp(y_axis[i][j+1].second,y_axis[i][j].second));
            }
        }
    }
    for(auto i:G){
        //cout<<i.first<<" "<<i.second<<"\n";
        if(Union(i.first,i.second)){
            choose.pb(mp(i.first,i.second));
        }
    }
    for(auto i:choose){
        //cout<<x[i.first]<<" "<<y[i.first]<<" "<<x[i.second]<<" "<<y[i.second]<<"\n";
        if(x[i.first]==x[i.second] && x[i.first]==2){
            u.pb(i.first);v.pb(i.second);a.pb(1);b.pb((y[i.first]+y[i.second])/2);
        }
        else if(x[i.first]==x[i.second] && x[i.first]==4){
            u.pb(i.first);v.pb(i.second);a.pb(5);b.pb((y[i.first]+y[i.second])/2);
        }
        else{
            u.pb(i.first);v.pb(i.second);a.pb(3);b.pb(y[i.first]+1);
        }
        //cout<<v.back()<<" \n";
    }
    //for(int i:v) cout<<i<<" ";
    if((int)choose.size()==(int)x.size()-1){
        build(u,v,a,b);
        return 1;
    }
    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
17 Correct 6 ms 10392 KB Output is correct
18 Correct 6 ms 10452 KB Output is correct
19 Correct 6 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 6 ms 10468 KB Output is correct
22 Correct 6 ms 10452 KB Output is correct
23 Correct 154 ms 37132 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10604 KB Output is correct
26 Correct 8 ms 10740 KB Output is correct
27 Correct 8 ms 10740 KB Output is correct
28 Correct 60 ms 21084 KB Output is correct
29 Correct 90 ms 26116 KB Output is correct
30 Correct 119 ms 32000 KB Output is correct
31 Correct 158 ms 37228 KB Output is correct
32 Correct 6 ms 10452 KB Output is correct
33 Correct 7 ms 10452 KB Output is correct
34 Correct 7 ms 10472 KB Output is correct
35 Correct 6 ms 10452 KB Output is correct
36 Correct 6 ms 10452 KB Output is correct
37 Correct 6 ms 10452 KB Output is correct
38 Correct 7 ms 10452 KB Output is correct
39 Correct 8 ms 10464 KB Output is correct
40 Correct 6 ms 10452 KB Output is correct
41 Correct 6 ms 10452 KB Output is correct
42 Correct 6 ms 10468 KB Output is correct
43 Correct 7 ms 10580 KB Output is correct
44 Correct 7 ms 10708 KB Output is correct
45 Correct 75 ms 23748 KB Output is correct
46 Correct 114 ms 30508 KB Output is correct
47 Correct 114 ms 30500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
17 Correct 6 ms 10392 KB Output is correct
18 Correct 6 ms 10452 KB Output is correct
19 Correct 6 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 6 ms 10468 KB Output is correct
22 Correct 6 ms 10452 KB Output is correct
23 Correct 154 ms 37132 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10604 KB Output is correct
26 Correct 8 ms 10740 KB Output is correct
27 Correct 8 ms 10740 KB Output is correct
28 Correct 60 ms 21084 KB Output is correct
29 Correct 90 ms 26116 KB Output is correct
30 Correct 119 ms 32000 KB Output is correct
31 Correct 158 ms 37228 KB Output is correct
32 Correct 6 ms 10452 KB Output is correct
33 Correct 7 ms 10452 KB Output is correct
34 Correct 7 ms 10472 KB Output is correct
35 Correct 6 ms 10452 KB Output is correct
36 Correct 6 ms 10452 KB Output is correct
37 Correct 6 ms 10452 KB Output is correct
38 Correct 7 ms 10452 KB Output is correct
39 Correct 8 ms 10464 KB Output is correct
40 Correct 6 ms 10452 KB Output is correct
41 Correct 6 ms 10452 KB Output is correct
42 Correct 6 ms 10468 KB Output is correct
43 Correct 7 ms 10580 KB Output is correct
44 Correct 7 ms 10708 KB Output is correct
45 Correct 75 ms 23748 KB Output is correct
46 Correct 114 ms 30508 KB Output is correct
47 Correct 114 ms 30500 KB Output is correct
48 Incorrect 7 ms 10452 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 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
17 Incorrect 8 ms 10476 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 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
17 Incorrect 175 ms 33956 KB Tree (a[50001], b[50001]) = (3, 3) is not adjacent to edge between u[50001]=134526 @(6, 2) and v[50001]=22196 @(4, 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10476 KB Output is correct
2 Correct 7 ms 10452 KB Output is correct
3 Correct 7 ms 10452 KB Output is correct
4 Correct 6 ms 10452 KB Output is correct
5 Correct 7 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 6 ms 10416 KB Output is correct
8 Correct 6 ms 10472 KB Output is correct
9 Correct 77 ms 23776 KB Output is correct
10 Correct 14 ms 11840 KB Output is correct
11 Correct 35 ms 17508 KB Output is correct
12 Correct 14 ms 12500 KB Output is correct
13 Correct 17 ms 14788 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 8 ms 10580 KB Output is correct
16 Correct 77 ms 23836 KB Output is correct
17 Correct 6 ms 10392 KB Output is correct
18 Correct 6 ms 10452 KB Output is correct
19 Correct 6 ms 10452 KB Output is correct
20 Correct 6 ms 10452 KB Output is correct
21 Correct 6 ms 10468 KB Output is correct
22 Correct 6 ms 10452 KB Output is correct
23 Correct 154 ms 37132 KB Output is correct
24 Correct 9 ms 10452 KB Output is correct
25 Correct 7 ms 10604 KB Output is correct
26 Correct 8 ms 10740 KB Output is correct
27 Correct 8 ms 10740 KB Output is correct
28 Correct 60 ms 21084 KB Output is correct
29 Correct 90 ms 26116 KB Output is correct
30 Correct 119 ms 32000 KB Output is correct
31 Correct 158 ms 37228 KB Output is correct
32 Correct 6 ms 10452 KB Output is correct
33 Correct 7 ms 10452 KB Output is correct
34 Correct 7 ms 10472 KB Output is correct
35 Correct 6 ms 10452 KB Output is correct
36 Correct 6 ms 10452 KB Output is correct
37 Correct 6 ms 10452 KB Output is correct
38 Correct 7 ms 10452 KB Output is correct
39 Correct 8 ms 10464 KB Output is correct
40 Correct 6 ms 10452 KB Output is correct
41 Correct 6 ms 10452 KB Output is correct
42 Correct 6 ms 10468 KB Output is correct
43 Correct 7 ms 10580 KB Output is correct
44 Correct 7 ms 10708 KB Output is correct
45 Correct 75 ms 23748 KB Output is correct
46 Correct 114 ms 30508 KB Output is correct
47 Correct 114 ms 30500 KB Output is correct
48 Incorrect 7 ms 10452 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 -