답안 #750669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750669 2023-05-30T05:55:46 Z drdilyor Drawing (CEOI22_drawing) C++17
0 / 100
241 ms 34704 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
mt19937 rng;

using pt = pair<int,int>;
bool ccw(pt A, pt B, pt C) {
    return (C.second-A.second) * (B.first-A.first) > (B.second-A.second) * (C.first-A.first);
}
bool intersect(pt A, pt B, pt C, pt D) {
    return ccw(A, C, D) != ccw(B, C, D) && ccw(A, B, C) != ccw(A, B, D);
}

int main() {

    int n;
    cin >> n;

    vector<vector<int>> adj(n);
    vector<pair<int,int>> pts(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    map<pair<int,int>, int> ix;
    for (auto& [x, y] : pts)
        cin >> x >> y;
    for (int i = 0; i < n; i++)
        ix[pts[i]]= i;

    vector<int> res(n, -1);
    while (true) {
        vector<pt> hull;
        sort(pts.begin(), pts.end());
        for (int i = 0; i < (int)pts.size();i ++) {
            while (hull.size() >= 2) {
                if (!ccw(hull.end()[-2], hull.end()[-1], pts[i]))
                    hull.pop_back();
                else break;
            }
            hull.push_back(pts[i]);
        }
        auto down = hull;
        hull = {};
        for (int i = (int)pts.size()-1; i >= 0; i--) {
            while (hull.size() >= 2) {
                if (!ccw(hull.end()[-2], hull.end()[-1], pts[i]))
                    hull.pop_back();
                else break;
            }
            hull.push_back(pts[i]);
        }
        for (int i = 1; i < (int)down.size()-1; i++) {
            hull.push_back(down[i]);
        }

        auto dfs = [&](auto& dfs, int i, int p)->void{
            res[i] = ix[hull.back()];
            hull.pop_back();
            for (int e : adj[i]) {
                if (e == p) continue;
                dfs(dfs, e, i);
            }
        };
        dfs(dfs, 0, -1);
        break;
    }
    for (int i : res) {
        assert(i >= 0);
        cout << i+1 << ' ';
    }
    cout << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 241 ms 34704 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 241 ms 34704 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -