Submission #816932

# Submission time Handle Problem Language Result Execution time Memory
816932 2023-08-09T07:36:34 Z ono_de206 Drawing (CEOI22_drawing) C++14
100 / 100
144 ms 16752 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
	out << c.first << ' ' << c.second;
    return out;
}

template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
	const int sz = v.size();
	for (int i = 0; i < sz; i++) {
		if (i) out << ' ';
		out << v[i];
	}
    return out;
}

template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
	for (T &x : v) in >> x;
    return in;
}


template<typename T>
void mxx(T &a, T b){if(b > a) a = b;}
template<typename T>
void mnn(T &a, T b){if(b < a) a = b;}

const int mxn = 2e5 + 10;
int vis[mxn], ans[mxn];
vector<int> g[mxn];

void go() {
	int n;
	cin >> n;
	for(int i = 1, x, y; i < n; i++) {
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	queue<int> q;
	vector<pair<pair<int, int>, int>> v;
	for(int i = 1; i <= n; i++) {
		int x, y;
		cin >> x >> y;
		v.eb(make_pair(x, y), i);
	}
	sort(all(v));
	int l = 0;
	q.push(1);
	vis[1] = 1;
	while(q.size()) {
		int x = q.front();
		q.pop();
		ans[x] = v[l++].ss;
		for(int y : g[x]) {
			if(vis[y]) continue;
			q.push(y);
			vis[y] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		vis[ans[i]] = i;
	}
	for(int i = 1; i <= n; i++) {
		cout << vis[i] << ' ';
	}
	cout << '\n';
}

signed main() {
	//#ifndef ONO
	//freopen("file.in", "r", stdin);
	//freopen("file.out", "w", stdout);
	//#endif
	fast;
	int t = 1;
	// cin >> t;
	while(t--) {
		go();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 63 ms 11584 KB Output is correct
2 Correct 67 ms 11516 KB Output is correct
3 Correct 64 ms 11576 KB Output is correct
4 Correct 90 ms 12236 KB Output is correct
5 Correct 73 ms 11272 KB Output is correct
6 Correct 65 ms 11500 KB Output is correct
7 Correct 78 ms 11588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 4 ms 5204 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 4 ms 5288 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 4 ms 5204 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 4 ms 5204 KB Output is correct
12 Correct 4 ms 5204 KB Output is correct
13 Correct 4 ms 5204 KB Output is correct
14 Correct 4 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 4 ms 5204 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 4 ms 5288 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 4 ms 5204 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 4 ms 5204 KB Output is correct
12 Correct 4 ms 5204 KB Output is correct
13 Correct 4 ms 5204 KB Output is correct
14 Correct 4 ms 5244 KB Output is correct
15 Correct 7 ms 5656 KB Output is correct
16 Correct 7 ms 5656 KB Output is correct
17 Correct 7 ms 5712 KB Output is correct
18 Correct 7 ms 5656 KB Output is correct
19 Correct 7 ms 5724 KB Output is correct
20 Correct 8 ms 5656 KB Output is correct
21 Correct 7 ms 5640 KB Output is correct
22 Correct 9 ms 5676 KB Output is correct
23 Correct 7 ms 5656 KB Output is correct
24 Correct 7 ms 5656 KB Output is correct
25 Correct 7 ms 5656 KB Output is correct
26 Correct 7 ms 5656 KB Output is correct
27 Correct 7 ms 5712 KB Output is correct
28 Correct 9 ms 5740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 4 ms 5204 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 4 ms 5288 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 4 ms 5204 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 4 ms 5204 KB Output is correct
12 Correct 4 ms 5204 KB Output is correct
13 Correct 4 ms 5204 KB Output is correct
14 Correct 4 ms 5244 KB Output is correct
15 Correct 7 ms 5656 KB Output is correct
16 Correct 7 ms 5656 KB Output is correct
17 Correct 7 ms 5712 KB Output is correct
18 Correct 7 ms 5656 KB Output is correct
19 Correct 7 ms 5724 KB Output is correct
20 Correct 8 ms 5656 KB Output is correct
21 Correct 7 ms 5640 KB Output is correct
22 Correct 9 ms 5676 KB Output is correct
23 Correct 7 ms 5656 KB Output is correct
24 Correct 7 ms 5656 KB Output is correct
25 Correct 7 ms 5656 KB Output is correct
26 Correct 7 ms 5656 KB Output is correct
27 Correct 7 ms 5712 KB Output is correct
28 Correct 9 ms 5740 KB Output is correct
29 Correct 47 ms 9640 KB Output is correct
30 Correct 47 ms 9636 KB Output is correct
31 Correct 47 ms 9620 KB Output is correct
32 Correct 44 ms 9660 KB Output is correct
33 Correct 43 ms 9672 KB Output is correct
34 Correct 45 ms 9632 KB Output is correct
35 Correct 44 ms 9664 KB Output is correct
36 Correct 45 ms 9080 KB Output is correct
37 Correct 49 ms 9668 KB Output is correct
38 Correct 47 ms 9600 KB Output is correct
39 Correct 46 ms 9616 KB Output is correct
40 Correct 43 ms 9640 KB Output is correct
41 Correct 38 ms 9080 KB Output is correct
42 Correct 52 ms 9648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 11584 KB Output is correct
2 Correct 67 ms 11516 KB Output is correct
3 Correct 64 ms 11576 KB Output is correct
4 Correct 90 ms 12236 KB Output is correct
5 Correct 73 ms 11272 KB Output is correct
6 Correct 65 ms 11500 KB Output is correct
7 Correct 78 ms 11588 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 4 ms 5204 KB Output is correct
10 Correct 5 ms 5204 KB Output is correct
11 Correct 4 ms 5204 KB Output is correct
12 Correct 4 ms 5204 KB Output is correct
13 Correct 4 ms 5288 KB Output is correct
14 Correct 4 ms 5204 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 4 ms 5204 KB Output is correct
17 Correct 4 ms 5204 KB Output is correct
18 Correct 4 ms 5204 KB Output is correct
19 Correct 4 ms 5204 KB Output is correct
20 Correct 4 ms 5204 KB Output is correct
21 Correct 4 ms 5244 KB Output is correct
22 Correct 7 ms 5656 KB Output is correct
23 Correct 7 ms 5656 KB Output is correct
24 Correct 7 ms 5712 KB Output is correct
25 Correct 7 ms 5656 KB Output is correct
26 Correct 7 ms 5724 KB Output is correct
27 Correct 8 ms 5656 KB Output is correct
28 Correct 7 ms 5640 KB Output is correct
29 Correct 9 ms 5676 KB Output is correct
30 Correct 7 ms 5656 KB Output is correct
31 Correct 7 ms 5656 KB Output is correct
32 Correct 7 ms 5656 KB Output is correct
33 Correct 7 ms 5656 KB Output is correct
34 Correct 7 ms 5712 KB Output is correct
35 Correct 9 ms 5740 KB Output is correct
36 Correct 47 ms 9640 KB Output is correct
37 Correct 47 ms 9636 KB Output is correct
38 Correct 47 ms 9620 KB Output is correct
39 Correct 44 ms 9660 KB Output is correct
40 Correct 43 ms 9672 KB Output is correct
41 Correct 45 ms 9632 KB Output is correct
42 Correct 44 ms 9664 KB Output is correct
43 Correct 45 ms 9080 KB Output is correct
44 Correct 49 ms 9668 KB Output is correct
45 Correct 47 ms 9600 KB Output is correct
46 Correct 46 ms 9616 KB Output is correct
47 Correct 43 ms 9640 KB Output is correct
48 Correct 38 ms 9080 KB Output is correct
49 Correct 52 ms 9648 KB Output is correct
50 Correct 89 ms 12220 KB Output is correct
51 Correct 136 ms 16476 KB Output is correct
52 Correct 138 ms 16524 KB Output is correct
53 Correct 137 ms 16608 KB Output is correct
54 Correct 127 ms 16520 KB Output is correct
55 Correct 141 ms 16752 KB Output is correct
56 Correct 120 ms 16524 KB Output is correct
57 Correct 24 ms 7500 KB Output is correct
58 Correct 131 ms 16548 KB Output is correct
59 Correct 119 ms 16576 KB Output is correct
60 Correct 143 ms 16604 KB Output is correct
61 Correct 144 ms 16612 KB Output is correct
62 Correct 28 ms 7488 KB Output is correct
63 Correct 136 ms 16596 KB Output is correct