Submission #644859

# Submission time Handle Problem Language Result Execution time Memory
644859 2022-09-25T11:39:15 Z Do_you_copy Drawing (CEOI22_drawing) C++17
65 / 100
86 ms 14868 KB
////////////////////////////
// Gke vay sao            //
////////////////////////////
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000007;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 1e5 + 1;
int n;

struct TPoint{
    int x, y, idx;
};

TPoint p[maxN];
vector <int> adj[maxN];
int sz[maxN];
int ans[maxN];
int x, y;

void pre_dfs(int u, int par){
    sz[u] = 1;
    for (int i: adj[u]){
        if (i == par) continue;
        pre_dfs(i, u);
        sz[u] += sz[i];
    }
}

void dfs(int u, int par, int idx){
    ans[p[idx].idx] = u;
    int tem = idx + 1;
    for (int i: adj[u]){
        if (i == par) continue;
        dfs(i, u, tem);
        tem += sz[i];
    }
}

void Init(){
    cin >> n;
    for (int i = 1; i < n; ++i){
        int u, v; cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    pre_dfs(1, 0);
    for (int i = 1; i <= n; ++i){
        cin >> p[i].x >> p[i].y;
        p[i].idx = i;
    }
    if (n == 1){
        cout << 1; return;
    }
    sort(p + 1, p + n + 1,[](const auto &i, const auto &j){
        //left bottom
        if (i.x == j.x) return i.y < j.y;
        return i.x < j.x;
    });
    x = p[1].x;
    y = p[1].y;
    sort(p + 2, p + n + 1,[&](const auto &i, const auto &j){
        //cross product
        return x * i.y - i.x * y > x * j.y - j.x * y;
    });
    dfs(1, 0, 1);
    for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
}

#define debu
#define taskname "test"
signed main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        #ifdef debug
        freopen(taskname".out", "w", stdout);
        #endif
    }
    faster;
    ll tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }
    #ifdef debug
        ofstream timeout("timeout.txt");
        timeout << signed(1000 * double(clock()) / CLOCKS_PER_SEC);
        timeout.close();
    #else
        cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n";
    #endif
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:97:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 14868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2936 KB Output is correct
2 Correct 6 ms 3084 KB Output is correct
3 Correct 4 ms 3092 KB Output is correct
4 Correct 5 ms 3188 KB Output is correct
5 Correct 5 ms 3156 KB Output is correct
6 Correct 4 ms 2900 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 4 ms 2900 KB Output is correct
9 Correct 5 ms 3072 KB Output is correct
10 Correct 5 ms 2948 KB Output is correct
11 Correct 4 ms 3216 KB Output is correct
12 Correct 4 ms 3092 KB Output is correct
13 Correct 4 ms 2824 KB Output is correct
14 Correct 5 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2936 KB Output is correct
2 Correct 6 ms 3084 KB Output is correct
3 Correct 4 ms 3092 KB Output is correct
4 Correct 5 ms 3188 KB Output is correct
5 Correct 5 ms 3156 KB Output is correct
6 Correct 4 ms 2900 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 4 ms 2900 KB Output is correct
9 Correct 5 ms 3072 KB Output is correct
10 Correct 5 ms 2948 KB Output is correct
11 Correct 4 ms 3216 KB Output is correct
12 Correct 4 ms 3092 KB Output is correct
13 Correct 4 ms 2824 KB Output is correct
14 Correct 5 ms 3028 KB Output is correct
15 Correct 8 ms 3412 KB Output is correct
16 Correct 9 ms 3796 KB Output is correct
17 Correct 8 ms 3540 KB Output is correct
18 Correct 9 ms 4052 KB Output is correct
19 Correct 12 ms 3944 KB Output is correct
20 Correct 10 ms 3412 KB Output is correct
21 Correct 8 ms 3668 KB Output is correct
22 Correct 9 ms 3412 KB Output is correct
23 Correct 9 ms 3544 KB Output is correct
24 Correct 9 ms 3540 KB Output is correct
25 Correct 9 ms 4192 KB Output is correct
26 Correct 8 ms 4052 KB Output is correct
27 Correct 9 ms 3412 KB Output is correct
28 Correct 11 ms 3444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2936 KB Output is correct
2 Correct 6 ms 3084 KB Output is correct
3 Correct 4 ms 3092 KB Output is correct
4 Correct 5 ms 3188 KB Output is correct
5 Correct 5 ms 3156 KB Output is correct
6 Correct 4 ms 2900 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 4 ms 2900 KB Output is correct
9 Correct 5 ms 3072 KB Output is correct
10 Correct 5 ms 2948 KB Output is correct
11 Correct 4 ms 3216 KB Output is correct
12 Correct 4 ms 3092 KB Output is correct
13 Correct 4 ms 2824 KB Output is correct
14 Correct 5 ms 3028 KB Output is correct
15 Correct 8 ms 3412 KB Output is correct
16 Correct 9 ms 3796 KB Output is correct
17 Correct 8 ms 3540 KB Output is correct
18 Correct 9 ms 4052 KB Output is correct
19 Correct 12 ms 3944 KB Output is correct
20 Correct 10 ms 3412 KB Output is correct
21 Correct 8 ms 3668 KB Output is correct
22 Correct 9 ms 3412 KB Output is correct
23 Correct 9 ms 3544 KB Output is correct
24 Correct 9 ms 3540 KB Output is correct
25 Correct 9 ms 4192 KB Output is correct
26 Correct 8 ms 4052 KB Output is correct
27 Correct 9 ms 3412 KB Output is correct
28 Correct 11 ms 3444 KB Output is correct
29 Correct 70 ms 8804 KB Output is correct
30 Correct 80 ms 12312 KB Output is correct
31 Correct 67 ms 10668 KB Output is correct
32 Correct 86 ms 14068 KB Output is correct
33 Correct 81 ms 13276 KB Output is correct
34 Correct 63 ms 8200 KB Output is correct
35 Correct 71 ms 9576 KB Output is correct
36 Correct 55 ms 8024 KB Output is correct
37 Correct 73 ms 11268 KB Output is correct
38 Correct 65 ms 11828 KB Output is correct
39 Correct 86 ms 12872 KB Output is correct
40 Correct 86 ms 11388 KB Output is correct
41 Correct 54 ms 7704 KB Output is correct
42 Correct 68 ms 9776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 14868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -