답안 #831908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831908 2023-08-20T17:25:31 Z arsijo 분수 공원 (IOI21_parks) C++17
45 / 100
369 ms 39004 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++){
        //assert(sol.count({x[i],y[i]}) + sol.count({x[i]+2,y[i]})+sol.count({x[i]+2,y[i]+2})+sol.count({x[i],y[i]+2}) < 4);
    }
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 310 ms 36196 KB Output is correct
21 Correct 328 ms 36224 KB Output is correct
22 Correct 316 ms 36264 KB Output is correct
23 Correct 272 ms 32268 KB Output is correct
24 Correct 157 ms 26024 KB Output is correct
25 Correct 163 ms 26116 KB Output is correct
26 Correct 154 ms 26032 KB Output is correct
27 Correct 326 ms 36236 KB Output is correct
28 Correct 319 ms 36208 KB Output is correct
29 Correct 359 ms 36212 KB Output is correct
30 Correct 343 ms 36168 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 19 ms 7172 KB Output is correct
33 Correct 63 ms 15492 KB Output is correct
34 Correct 302 ms 36244 KB Output is correct
35 Correct 8 ms 6100 KB Output is correct
36 Correct 33 ms 10240 KB Output is correct
37 Correct 69 ms 15464 KB Output is correct
38 Correct 116 ms 17732 KB Output is correct
39 Correct 165 ms 22324 KB Output is correct
40 Correct 221 ms 27760 KB Output is correct
41 Correct 303 ms 32052 KB Output is correct
42 Correct 355 ms 36676 KB Output is correct
43 Correct 2 ms 4948 KB Output is correct
44 Correct 2 ms 4948 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 4948 KB Output is correct
49 Correct 2 ms 4948 KB Output is correct
50 Correct 2 ms 4948 KB Output is correct
51 Correct 2 ms 4948 KB Output is correct
52 Correct 2 ms 4948 KB Output is correct
53 Correct 2 ms 4948 KB Output is correct
54 Correct 3 ms 5204 KB Output is correct
55 Correct 3 ms 5204 KB Output is correct
56 Correct 138 ms 20836 KB Output is correct
57 Correct 206 ms 28132 KB Output is correct
58 Correct 215 ms 28332 KB Output is correct
59 Correct 3 ms 4948 KB Output is correct
60 Correct 2 ms 4948 KB Output is correct
61 Correct 2 ms 4948 KB Output is correct
62 Correct 287 ms 36280 KB Output is correct
63 Correct 283 ms 37552 KB Output is correct
64 Correct 288 ms 36808 KB Output is correct
65 Correct 4 ms 5332 KB Output is correct
66 Correct 6 ms 5844 KB Output is correct
67 Correct 134 ms 20688 KB Output is correct
68 Correct 233 ms 29224 KB Output is correct
69 Correct 360 ms 36160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 KB Output is correct
17 Correct 307 ms 36932 KB Output is correct
18 Correct 299 ms 37008 KB Output is correct
19 Correct 338 ms 36360 KB Output is correct
20 Correct 367 ms 39004 KB Output is correct
21 Correct 306 ms 33460 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 45 ms 10280 KB Output is correct
24 Correct 14 ms 7132 KB Output is correct
25 Correct 49 ms 12712 KB Output is correct
26 Correct 86 ms 17688 KB Output is correct
27 Correct 168 ms 21640 KB Output is correct
28 Correct 206 ms 26088 KB Output is correct
29 Correct 265 ms 30288 KB Output is correct
30 Correct 311 ms 33832 KB Output is correct
31 Correct 369 ms 37620 KB Output is correct
32 Correct 343 ms 38724 KB Output is correct
33 Correct 300 ms 37664 KB Output is correct
34 Correct 5 ms 5460 KB Output is correct
35 Correct 7 ms 6100 KB Output is correct
36 Correct 134 ms 20932 KB Output is correct
37 Correct 231 ms 29080 KB Output is correct
38 Correct 366 ms 36904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 5076 KB Output is correct
9 Correct 123 ms 20596 KB Output is correct
10 Correct 10 ms 6612 KB Output is correct
11 Correct 47 ms 13352 KB Output is correct
12 Correct 14 ms 7324 KB Output is correct
13 Correct 18 ms 9668 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5204 KB Output is correct
16 Correct 129 ms 20556 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 -