Submission #750671

# Submission time Handle Problem Language Result Execution time Memory
750671 2023-05-30T06:02:39 Z drdilyor Drawing (CEOI22_drawing) C++17
0 / 100
398 ms 18760 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 ll(C.second-A.second) * (B.first-A.first) > ll(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]);
        }
        for (auto[x,y] : hull)
            cout << x << ' ' << y << endl;

        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;
    }
    vector<int> byp(n);
    for (int i = 0; i < n; i++)
        assert(res[i] >= 0),
        byp[res[i]] = i;
    for (int i : byp) {
        cout << i+1 << ' ';
    }
    cout << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 398 ms 18760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 398 ms 18760 KB Output isn't correct
2 Halted 0 ms 0 KB -