This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
struct point{
ll x;
ll y;
int id;
bool operator< (const point &pp) const {
if(x == pp.x)
return y < pp.y;
return x < pp.x;
}
};
const int N = (int)2e5 + 10;
vector<int> T[N];
int P[N];
int tt = 0;
vector<point> pp;
void dfs(int u, int par){
P[pp[tt].id]=u;
tt++;
for(auto x : T[u]){
if(x == par) continue;
dfs(x, u);
}
}
int main(){
fastIO;
int n;
cin >> n;
int u, v;
for(int i = 1; i < n; i ++ ){
cin >> u >> v;
T[u].push_back(v);
T[v].push_back(u);
}
pp.resize(n);
for(int i = 0 ; i < n; i ++) {
cin >> pp[i].x >> pp[i].y;
pp[i].id = i;
}
sort(pp.begin(), pp.end());
dfs(1, -1);
for(int i = 0 ; i < n; i ++ ){
cout << P[i] << " ";
}
cout << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |