답안 #759474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759474 2023-06-16T10:42:03 Z drdilyor 분수 공원 (IOI21_parks) C++17
0 / 100
0 ms 212 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
        build({}, {}, {}, {});
        return 1;
    }

    int n = x.size();

    std::vector<int> u, v, a, b;
    map<pair<int,int>, int> ft;
    for (int i = 0; i < n;i ++)
        ft[{x[i], y[i]}] = i;
    set<pair<int,int>> bench;

    for (int i = 0; i < n; i++) {
        for (auto [dx, dy] : {pair{0, -2}, {0, +2}, {-2, 0}, {+2, 0}}) {
            pair pos{x[i]+dx, y[i]+dx};
            if (!ft.count(pos)) continue;
            int j = ft[pos];
            u.push_back(i);
            v.push_back(j);
            vector<pair<int,int>> pos_bench;
            if (dx) {
                pos_bench = {{x[i], y[i]+1}, {x[i], y[i]-1}};
            } else {
                pos_bench = {{x[i]+1, y[i]}, {x[i]-1, y[i]}};
            }
            bool done = 0;
            for (auto pos : pos_bench) {
                if (bench.count(pos) == 0) {
                    done = 1;
                    a.push_back(pos.first);
                    b.push_back(pos.second);
                    break;
                }
            }
            if (!done) return 0;
        }
    }

    build(u, v, a, b);

    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2)
3 Halted 0 ms 0 KB -