답안 #1050553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050553 2024-08-09T11:01:18 Z Malix 분수 공원 (IOI21_parks) C++17
5 / 100
593 ms 55200 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))

ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

map<pi,pi> p;
map<pi,int> s,num;

pi parent(pi x){
    if(p[x]==x)return x;
    return p[x]=parent(p[x]);
}

void join(pi x,pi y){
    x=parent(x);
    y=parent(y);
    if(x==y)return;
    s[x]+=s[y];
    p[y]=x;
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    int n=x.size();
    int mx=0;
    REP(i,0,n)mx=max(mx,x[i]);
if(mx==2){
    pii a;
    REP(i,0,n)a.PB({y[i],i});
    sort(a.begin(),a.end());
    vii ans(4);
    REP(i,0,n-1){
        if(a[i].F+2!=a[i+1].F)return 0;
        ans[0].PB(a[i].S);
        ans[1].PB(a[i+1].S);
        ans[2].PB(3);
        ans[3].PB(a[i].F+1);
    }
    build(ans[0],ans[1],ans[2],ans[3]);
    return 1;
}
if(mx==4){
    REP(i,0,n)s[{x[i],y[i]}]=1;
    REP(i,0,n)p[{x[i],y[i]}]={x[i],y[i]};
    REP(i,0,n)num[{x[i],y[i]}]=i;
    vii ans(4);
    REP(i,2,5){
        REP(j,2,200000-1){
            if(s[{i,j}]>0&&s[{i,j+2}]>0){
                join({i,j},{i,j+2});
                ans[0].PB(num[{i,j}]);
                ans[1].PB(num[{i,j+2}]);
                if(i==2)ans[2].PB(i-1);
                else ans[2].PB(i+1);
                ans[3].PB(j+1);
            }
            if(i==2&&s[{i,j}]>0&&s[{i+2,j}]>0){
                join({i,j},{i+2,j});
                ans[0].PB(num[{i,j}]);
                ans[1].PB(num[{i+2,j}]);
                ans[2].PB(i+1);
                ans[3].PB(j-1);
            }
            j++;
        }
        i++;
    }
    pi t=parent({x[0],y[0]});
    bool flag=1;
    REP(i,0,n)if(parent({x[i],y[i]})!=t)flag=0;
    if(flag){
        build(ans[0],ans[1],ans[2],ans[3]);
        return 1;
    }
    return 0;
}
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
17 Correct 37 ms 12884 KB Output is correct
18 Correct 35 ms 12888 KB Output is correct
19 Correct 35 ms 12784 KB Output is correct
20 Correct 43 ms 12912 KB Output is correct
21 Correct 42 ms 12908 KB Output is correct
22 Correct 37 ms 12884 KB Output is correct
23 Correct 593 ms 55200 KB Output is correct
24 Correct 39 ms 12880 KB Output is correct
25 Correct 40 ms 13096 KB Output is correct
26 Correct 42 ms 13392 KB Output is correct
27 Correct 44 ms 13396 KB Output is correct
28 Correct 205 ms 29880 KB Output is correct
29 Correct 334 ms 38340 KB Output is correct
30 Correct 475 ms 46764 KB Output is correct
31 Correct 586 ms 55196 KB Output is correct
32 Correct 36 ms 12880 KB Output is correct
33 Correct 35 ms 12884 KB Output is correct
34 Correct 35 ms 12880 KB Output is correct
35 Correct 39 ms 12892 KB Output is correct
36 Correct 37 ms 12880 KB Output is correct
37 Correct 40 ms 12820 KB Output is correct
38 Correct 42 ms 12880 KB Output is correct
39 Correct 37 ms 12880 KB Output is correct
40 Correct 36 ms 12888 KB Output is correct
41 Correct 36 ms 12884 KB Output is correct
42 Incorrect 38 ms 12884 KB Solution announced impossible, but it is possible.
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
17 Correct 37 ms 12884 KB Output is correct
18 Correct 35 ms 12888 KB Output is correct
19 Correct 35 ms 12784 KB Output is correct
20 Correct 43 ms 12912 KB Output is correct
21 Correct 42 ms 12908 KB Output is correct
22 Correct 37 ms 12884 KB Output is correct
23 Correct 593 ms 55200 KB Output is correct
24 Correct 39 ms 12880 KB Output is correct
25 Correct 40 ms 13096 KB Output is correct
26 Correct 42 ms 13392 KB Output is correct
27 Correct 44 ms 13396 KB Output is correct
28 Correct 205 ms 29880 KB Output is correct
29 Correct 334 ms 38340 KB Output is correct
30 Correct 475 ms 46764 KB Output is correct
31 Correct 586 ms 55196 KB Output is correct
32 Correct 36 ms 12880 KB Output is correct
33 Correct 35 ms 12884 KB Output is correct
34 Correct 35 ms 12880 KB Output is correct
35 Correct 39 ms 12892 KB Output is correct
36 Correct 37 ms 12880 KB Output is correct
37 Correct 40 ms 12820 KB Output is correct
38 Correct 42 ms 12880 KB Output is correct
39 Correct 37 ms 12880 KB Output is correct
40 Correct 36 ms 12888 KB Output is correct
41 Correct 36 ms 12884 KB Output is correct
42 Incorrect 38 ms 12884 KB Solution announced impossible, but it is possible.
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
17 Incorrect 1 ms 344 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
17 Incorrect 19 ms 3416 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 32 ms 8272 KB Output is correct
10 Correct 3 ms 1292 KB Output is correct
11 Correct 14 ms 4484 KB Output is correct
12 Correct 4 ms 1508 KB Output is correct
13 Correct 5 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 34 ms 8144 KB Output is correct
17 Correct 37 ms 12884 KB Output is correct
18 Correct 35 ms 12888 KB Output is correct
19 Correct 35 ms 12784 KB Output is correct
20 Correct 43 ms 12912 KB Output is correct
21 Correct 42 ms 12908 KB Output is correct
22 Correct 37 ms 12884 KB Output is correct
23 Correct 593 ms 55200 KB Output is correct
24 Correct 39 ms 12880 KB Output is correct
25 Correct 40 ms 13096 KB Output is correct
26 Correct 42 ms 13392 KB Output is correct
27 Correct 44 ms 13396 KB Output is correct
28 Correct 205 ms 29880 KB Output is correct
29 Correct 334 ms 38340 KB Output is correct
30 Correct 475 ms 46764 KB Output is correct
31 Correct 586 ms 55196 KB Output is correct
32 Correct 36 ms 12880 KB Output is correct
33 Correct 35 ms 12884 KB Output is correct
34 Correct 35 ms 12880 KB Output is correct
35 Correct 39 ms 12892 KB Output is correct
36 Correct 37 ms 12880 KB Output is correct
37 Correct 40 ms 12820 KB Output is correct
38 Correct 42 ms 12880 KB Output is correct
39 Correct 37 ms 12880 KB Output is correct
40 Correct 36 ms 12888 KB Output is correct
41 Correct 36 ms 12884 KB Output is correct
42 Incorrect 38 ms 12884 KB Solution announced impossible, but it is possible.
43 Halted 0 ms 0 KB -