답안 #1051887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051887 2024-08-10T10:25:33 Z MarwenElarbi 분수 공원 (IOI21_parks) C++17
15 / 100
355 ms 47700 KB
#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
const int nax=2e5+5;
set<pair<int,int>> mp;
map<pair<int,int>,int> cor;
set<pair<int,int>> vis;
int parent[nax];
bool check(pair<int,int> a){
    if(!mp.count({a.fi-2,a.se})&&!mp.count({a.fi+2,a.se})&&!mp.count({a.fi,a.se-2})&&!mp.count({a.fi,a.se+2})) return false;
    return true; 
}
int find(int x){
    if(x==parent[x]) return x;
    return parent[x]=find(parent[x]);
}
bool sameset(int x,int y){
    return find(x)==find(y);
}
void joinset(int x,int y) {
    x=find(x);
    y=find(y);
    parent[x]=y;
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    int n=y.size();
    for (int i = 0; i < n; ++i) parent[i]=i;
    for (int i = 0; i < n; ++i)
    {
        mp.insert({x[i],y[i]});
        cor[{x[i],y[i]}]=i;
    }
    bool test=true;
    for(auto i:mp){
        if(!check(i)){
            test=false;
            break;
        }
        if(mp.count({i.fi+2,i.se})){
            if(sameset(cor[i],cor[{i.fi+2,i.se}])) continue;
            pair<int,int> cur={i.fi+1,i.se+1};
            if(vis.count(cur)) cur.se-=2;
            vis.insert(cur);
            joinset(cor[i],cor[{i.fi+2,i.se}]);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi+2,i.se}]);
        }
        if(mp.count({i.fi,i.se+2})){
            if(sameset(cor[i],cor[{i.fi,i.se+2}])) continue;
            joinset(cor[i],cor[{i.fi,i.se+2}]);
            pair<int,int> cur={i.fi+1,i.se+1};
            if(vis.count(cur)) cur.fi-=2;
            vis.insert(cur);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi,i.se+2}]);
        }
    }
    if(!test) return 0;
    if((int)u.size()!=n-1) return 0;
    build(u, v, a, b);
    return 1;
}
# 결과 실행 시간 메모리 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 347 ms 47700 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 5 ms 1116 KB Output is correct
28 Correct 106 ms 19128 KB Output is correct
29 Correct 198 ms 28596 KB Output is correct
30 Correct 290 ms 38116 KB Output is correct
31 Correct 354 ms 47668 KB Output is correct
32 Correct 0 ms 356 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 158 ms 22552 KB Output is correct
46 Correct 208 ms 32680 KB Output is correct
47 Correct 204 ms 32676 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 347 ms 47700 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 5 ms 1116 KB Output is correct
28 Correct 106 ms 19128 KB Output is correct
29 Correct 198 ms 28596 KB Output is correct
30 Correct 290 ms 38116 KB Output is correct
31 Correct 354 ms 47668 KB Output is correct
32 Correct 0 ms 356 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 158 ms 22552 KB Output is correct
46 Correct 208 ms 32680 KB Output is correct
47 Correct 204 ms 32676 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Incorrect 0 ms 348 KB Tree @(3, 5) appears more than once: for edges on positions 2 and 4
52 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 321 ms 44852 KB Output is correct
21 Correct 296 ms 44968 KB Output is correct
22 Correct 350 ms 44968 KB Output is correct
23 Correct 237 ms 38560 KB Output is correct
24 Correct 145 ms 26196 KB Output is correct
25 Correct 289 ms 38564 KB Output is correct
26 Correct 271 ms 38676 KB Output is correct
27 Incorrect 305 ms 45060 KB Tree @(5, 3) appears more than once: for edges on positions 499 and 501
28 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 KB Output is correct
17 Correct 355 ms 45644 KB Output is correct
18 Incorrect 327 ms 47528 KB Tree @(50001, 50003) appears more than once: for edges on positions 74999 and 100000
19 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 158 ms 22644 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 72 ms 12296 KB Output is correct
12 Correct 21 ms 3932 KB Output is correct
13 Correct 46 ms 8780 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 152 ms 22628 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 347 ms 47700 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 5 ms 1116 KB Output is correct
28 Correct 106 ms 19128 KB Output is correct
29 Correct 198 ms 28596 KB Output is correct
30 Correct 290 ms 38116 KB Output is correct
31 Correct 354 ms 47668 KB Output is correct
32 Correct 0 ms 356 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 158 ms 22552 KB Output is correct
46 Correct 208 ms 32680 KB Output is correct
47 Correct 204 ms 32676 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Incorrect 0 ms 348 KB Tree @(3, 5) appears more than once: for edges on positions 2 and 4
52 Halted 0 ms 0 KB -