답안 #593782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593782 2022-07-11T15:17:00 Z SlavicG 분수 공원 (IOI21_parks) C++17
5 / 100
247 ms 30520 KB
#include "parks.h"
#include "bits/stdc++.h"
using namespace std;

#define         sz(a)     (int)a.size()
#define        all(a)     a.begin(),a.end()
#define    forn(i, n)     for(int i = 0; i < n; ++i)

const int N = 2e5 + 10;
int p[N];
int get(int a) {
    return p[a] = (a == p[a] ? a : get(p[a]));
}
bool uni(int a, int b) {
    a = get(a), b = get(b);
    if(a == b) return false;
    p[a] = b;
    return true;
}

int construct_roads(vector<int> x, vector<int> y) {
    forn(i, N) p[i] = i;
    if (x.size() == 1) {
        build({}, {}, {}, {});
        return 1;
    }
    vector<int> u, v, a, b;
    vector<pair<int, int>> points;
    map<pair<int, int>, int> idx;
    vector<int> bruh[N];
    for(int i = 0; i < sz(x); ++i) {
        bruh[y[i]].push_back(i);
        idx[{x[i], y[i]}] = i;
        points.push_back({x[i], y[i]});
    }
    sort(all(points));
    for(int i = 0; i + 1 < sz(points); ++i) {
        if(points[i].first == points[i + 1].first) {
            if(points[i].second + 2 != points[i + 1].second) continue;
            if(points[i].first == 2 && uni(idx[points[i]], idx[points[i + 1]])) {
                u.push_back(idx[points[i]]), v.push_back(idx[points[i + 1]]);
                a.push_back(points[i].first - 1);
                b.push_back(points[i].second + 1);
            } else if(points[i].first == 4 && uni(idx[points[i]], idx[points[i + 1]])) {
                u.push_back(idx[points[i]]), v.push_back(idx[points[i + 1]]);
                a.push_back(points[i].first + 1);
                b.push_back(points[i].second + 1);
            }
        }
    }
    for(auto v: bruh) {
        if(sz(v) == 2) {
            if(uni(v[0], v[1])) {
                u.push_back(v[0]);
                u.push_back(v[1]);
                a.push_back(3);
                b.push_back(y[v[0]] - 1);
            }
        }
    }
    for(int i = 1; i < sz(x); ++i) {
        if(get(i) != get(0)) return 0;
    }
    build(u, v, a, b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
17 Incorrect 3 ms 5716 KB Wrong answer detected in grader
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
17 Incorrect 3 ms 5716 KB Wrong answer detected in grader
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
17 Incorrect 3 ms 5716 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
17 Incorrect 247 ms 30520 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 4 ms 5752 KB Output is correct
5 Correct 4 ms 5716 KB Output is correct
6 Correct 3 ms 5716 KB Output is correct
7 Correct 3 ms 5716 KB Output is correct
8 Correct 4 ms 5684 KB Output is correct
9 Correct 167 ms 24792 KB Output is correct
10 Correct 14 ms 7684 KB Output is correct
11 Correct 73 ms 16132 KB Output is correct
12 Correct 20 ms 8668 KB Output is correct
13 Correct 39 ms 12908 KB Output is correct
14 Correct 4 ms 5820 KB Output is correct
15 Correct 5 ms 6076 KB Output is correct
16 Correct 188 ms 24592 KB Output is correct
17 Incorrect 3 ms 5716 KB Wrong answer detected in grader
18 Halted 0 ms 0 KB -