답안 #645010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645010 2022-09-25T21:30:46 Z kingfran1907 Drawing (CEOI22_drawing) C++14
100 / 100
254 ms 45940 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 1e6+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
vector< int > graph[maxn];
pair< pair<int, int>, int > niz[maxn];
int sol[maxn];

llint f(pair<int, int> a, pair<int, int> b) {
	return (llint)a.X * b.Y - (llint)a.Y * b.X;
}

bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
	return f(niz[0].X, a.X) > f(niz[0].X, b.X);
}

int t = 0;
void solve(int x, int parr) {
	//printf("solve: %d\n", x);
	sol[x] = niz[t++].Y;
	for (int tren : graph[x]) {
		if (tren == parr) continue;
		solve(tren, x);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		niz[i] = {{x, y}, i + 1};
	}

	sort(niz, niz+n);
	sort(niz+1, niz+n, cmp);
	//for (int i = 0; i < n; i++) 
	//	printf("%d %d -- %d\n", niz[i].X.X, niz[i].X.Y, niz[i].Y);

	solve(1, 0);
	for (int i = 1; i <= n; i++) printf("%d ", sol[i]);
	printf("\n");
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
Main.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d%d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 29744 KB Output is correct
2 Correct 123 ms 35080 KB Output is correct
3 Correct 112 ms 33060 KB Output is correct
4 Correct 140 ms 36140 KB Output is correct
5 Correct 123 ms 36472 KB Output is correct
6 Correct 113 ms 31284 KB Output is correct
7 Correct 135 ms 32332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23992 KB Output is correct
2 Correct 15 ms 24052 KB Output is correct
3 Correct 14 ms 24148 KB Output is correct
4 Correct 15 ms 24120 KB Output is correct
5 Correct 15 ms 24184 KB Output is correct
6 Correct 15 ms 23912 KB Output is correct
7 Correct 16 ms 24108 KB Output is correct
8 Correct 15 ms 23960 KB Output is correct
9 Correct 16 ms 24148 KB Output is correct
10 Correct 18 ms 24020 KB Output is correct
11 Correct 17 ms 24148 KB Output is correct
12 Correct 18 ms 24148 KB Output is correct
13 Correct 19 ms 23972 KB Output is correct
14 Correct 15 ms 24020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23992 KB Output is correct
2 Correct 15 ms 24052 KB Output is correct
3 Correct 14 ms 24148 KB Output is correct
4 Correct 15 ms 24120 KB Output is correct
5 Correct 15 ms 24184 KB Output is correct
6 Correct 15 ms 23912 KB Output is correct
7 Correct 16 ms 24108 KB Output is correct
8 Correct 15 ms 23960 KB Output is correct
9 Correct 16 ms 24148 KB Output is correct
10 Correct 18 ms 24020 KB Output is correct
11 Correct 17 ms 24148 KB Output is correct
12 Correct 18 ms 24148 KB Output is correct
13 Correct 19 ms 23972 KB Output is correct
14 Correct 15 ms 24020 KB Output is correct
15 Correct 19 ms 24440 KB Output is correct
16 Correct 19 ms 24676 KB Output is correct
17 Correct 22 ms 24472 KB Output is correct
18 Correct 20 ms 24812 KB Output is correct
19 Correct 26 ms 24788 KB Output is correct
20 Correct 21 ms 24436 KB Output is correct
21 Correct 20 ms 24660 KB Output is correct
22 Correct 21 ms 24396 KB Output is correct
23 Correct 19 ms 24584 KB Output is correct
24 Correct 20 ms 24568 KB Output is correct
25 Correct 21 ms 24912 KB Output is correct
26 Correct 20 ms 24788 KB Output is correct
27 Correct 22 ms 24504 KB Output is correct
28 Correct 20 ms 24396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23992 KB Output is correct
2 Correct 15 ms 24052 KB Output is correct
3 Correct 14 ms 24148 KB Output is correct
4 Correct 15 ms 24120 KB Output is correct
5 Correct 15 ms 24184 KB Output is correct
6 Correct 15 ms 23912 KB Output is correct
7 Correct 16 ms 24108 KB Output is correct
8 Correct 15 ms 23960 KB Output is correct
9 Correct 16 ms 24148 KB Output is correct
10 Correct 18 ms 24020 KB Output is correct
11 Correct 17 ms 24148 KB Output is correct
12 Correct 18 ms 24148 KB Output is correct
13 Correct 19 ms 23972 KB Output is correct
14 Correct 15 ms 24020 KB Output is correct
15 Correct 19 ms 24440 KB Output is correct
16 Correct 19 ms 24676 KB Output is correct
17 Correct 22 ms 24472 KB Output is correct
18 Correct 20 ms 24812 KB Output is correct
19 Correct 26 ms 24788 KB Output is correct
20 Correct 21 ms 24436 KB Output is correct
21 Correct 20 ms 24660 KB Output is correct
22 Correct 21 ms 24396 KB Output is correct
23 Correct 19 ms 24584 KB Output is correct
24 Correct 20 ms 24568 KB Output is correct
25 Correct 21 ms 24912 KB Output is correct
26 Correct 20 ms 24788 KB Output is correct
27 Correct 22 ms 24504 KB Output is correct
28 Correct 20 ms 24396 KB Output is correct
29 Correct 83 ms 29620 KB Output is correct
30 Correct 85 ms 31560 KB Output is correct
31 Correct 90 ms 30684 KB Output is correct
32 Correct 78 ms 32452 KB Output is correct
33 Correct 83 ms 32328 KB Output is correct
34 Correct 90 ms 28928 KB Output is correct
35 Correct 85 ms 29948 KB Output is correct
36 Correct 76 ms 28868 KB Output is correct
37 Correct 84 ms 30924 KB Output is correct
38 Correct 91 ms 31404 KB Output is correct
39 Correct 88 ms 31832 KB Output is correct
40 Correct 87 ms 30828 KB Output is correct
41 Correct 86 ms 28388 KB Output is correct
42 Correct 81 ms 30136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 29744 KB Output is correct
2 Correct 123 ms 35080 KB Output is correct
3 Correct 112 ms 33060 KB Output is correct
4 Correct 140 ms 36140 KB Output is correct
5 Correct 123 ms 36472 KB Output is correct
6 Correct 113 ms 31284 KB Output is correct
7 Correct 135 ms 32332 KB Output is correct
8 Correct 15 ms 23992 KB Output is correct
9 Correct 15 ms 24052 KB Output is correct
10 Correct 14 ms 24148 KB Output is correct
11 Correct 15 ms 24120 KB Output is correct
12 Correct 15 ms 24184 KB Output is correct
13 Correct 15 ms 23912 KB Output is correct
14 Correct 16 ms 24108 KB Output is correct
15 Correct 15 ms 23960 KB Output is correct
16 Correct 16 ms 24148 KB Output is correct
17 Correct 18 ms 24020 KB Output is correct
18 Correct 17 ms 24148 KB Output is correct
19 Correct 18 ms 24148 KB Output is correct
20 Correct 19 ms 23972 KB Output is correct
21 Correct 15 ms 24020 KB Output is correct
22 Correct 19 ms 24440 KB Output is correct
23 Correct 19 ms 24676 KB Output is correct
24 Correct 22 ms 24472 KB Output is correct
25 Correct 20 ms 24812 KB Output is correct
26 Correct 26 ms 24788 KB Output is correct
27 Correct 21 ms 24436 KB Output is correct
28 Correct 20 ms 24660 KB Output is correct
29 Correct 21 ms 24396 KB Output is correct
30 Correct 19 ms 24584 KB Output is correct
31 Correct 20 ms 24568 KB Output is correct
32 Correct 21 ms 24912 KB Output is correct
33 Correct 20 ms 24788 KB Output is correct
34 Correct 22 ms 24504 KB Output is correct
35 Correct 20 ms 24396 KB Output is correct
36 Correct 83 ms 29620 KB Output is correct
37 Correct 85 ms 31560 KB Output is correct
38 Correct 90 ms 30684 KB Output is correct
39 Correct 78 ms 32452 KB Output is correct
40 Correct 83 ms 32328 KB Output is correct
41 Correct 90 ms 28928 KB Output is correct
42 Correct 85 ms 29948 KB Output is correct
43 Correct 76 ms 28868 KB Output is correct
44 Correct 84 ms 30924 KB Output is correct
45 Correct 91 ms 31404 KB Output is correct
46 Correct 88 ms 31832 KB Output is correct
47 Correct 87 ms 30828 KB Output is correct
48 Correct 86 ms 28388 KB Output is correct
49 Correct 81 ms 30136 KB Output is correct
50 Correct 131 ms 32324 KB Output is correct
51 Correct 239 ms 42304 KB Output is correct
52 Correct 235 ms 39976 KB Output is correct
53 Correct 240 ms 42612 KB Output is correct
54 Correct 244 ms 45940 KB Output is correct
55 Correct 220 ms 36728 KB Output is correct
56 Correct 253 ms 37580 KB Output is correct
57 Correct 50 ms 26604 KB Output is correct
58 Correct 238 ms 39956 KB Output is correct
59 Correct 254 ms 39664 KB Output is correct
60 Correct 253 ms 45236 KB Output is correct
61 Correct 235 ms 41864 KB Output is correct
62 Correct 48 ms 26516 KB Output is correct
63 Correct 247 ms 37604 KB Output is correct