답안 #1051892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051892 2024-08-10T10:27:49 Z MarwenElarbi 분수 공원 (IOI21_parks) C++17
15 / 100
366 ms 47688 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;
            if(vis.count(cur)) continue;
            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;
            if(vis.count(cur)) continue;
            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 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 KB Output is correct
17 Correct 0 ms 344 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 342 ms 47688 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 115 ms 19172 KB Output is correct
29 Correct 201 ms 28596 KB Output is correct
30 Correct 262 ms 38052 KB Output is correct
31 Correct 361 ms 47528 KB Output is correct
32 Correct 1 ms 348 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 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 4 ms 860 KB Output is correct
45 Correct 153 ms 22732 KB Output is correct
46 Correct 264 ms 32680 KB Output is correct
47 Correct 253 ms 32700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 KB Output is correct
17 Correct 0 ms 344 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 342 ms 47688 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 115 ms 19172 KB Output is correct
29 Correct 201 ms 28596 KB Output is correct
30 Correct 262 ms 38052 KB Output is correct
31 Correct 361 ms 47528 KB Output is correct
32 Correct 1 ms 348 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 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 4 ms 860 KB Output is correct
45 Correct 153 ms 22732 KB Output is correct
46 Correct 264 ms 32680 KB Output is correct
47 Correct 253 ms 32700 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 600 KB Output is correct
51 Incorrect 0 ms 348 KB Solution announced impossible, but it is possible.
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 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 344 KB Output is correct
20 Correct 366 ms 44956 KB Output is correct
21 Correct 365 ms 45044 KB Output is correct
22 Correct 318 ms 44964 KB Output is correct
23 Correct 256 ms 38564 KB Output is correct
24 Correct 114 ms 26256 KB Output is correct
25 Correct 291 ms 38568 KB Output is correct
26 Correct 286 ms 38568 KB Output is correct
27 Incorrect 269 ms 38780 KB Solution announced impossible, but it is possible.
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 KB Output is correct
17 Correct 312 ms 45732 KB Output is correct
18 Incorrect 283 ms 38984 KB Solution announced impossible, but it is possible.
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 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 136 ms 22712 KB Output is correct
10 Correct 10 ms 2648 KB Output is correct
11 Correct 67 ms 12228 KB Output is correct
12 Correct 15 ms 3932 KB Output is correct
13 Correct 45 ms 8904 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 148 ms 22616 KB Output is correct
17 Correct 0 ms 344 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 342 ms 47688 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 115 ms 19172 KB Output is correct
29 Correct 201 ms 28596 KB Output is correct
30 Correct 262 ms 38052 KB Output is correct
31 Correct 361 ms 47528 KB Output is correct
32 Correct 1 ms 348 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 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 4 ms 860 KB Output is correct
45 Correct 153 ms 22732 KB Output is correct
46 Correct 264 ms 32680 KB Output is correct
47 Correct 253 ms 32700 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 600 KB Output is correct
51 Incorrect 0 ms 348 KB Solution announced impossible, but it is possible.
52 Halted 0 ms 0 KB -