답안 #645008

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

using namespace std;
typedef long long llint;

const int maxn = 2e5+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;
int 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 solve(int, int)':
Main.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
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 Runtime error 100 ms 22416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 10324 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 10324 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 10324 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 22416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -