QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#1292. 电路板设计

Statistics

你受雇于纳米布线高效路由公司 (Nano Wiring Efficient Route Company, NWERC),以协助他们设计新型电路板。电路本身已经设计好了,你的任务是想出一种方法将它们印在公司购买的空白电路板上。

更具体地说,每个电路设计都包含若干连接点以及它们之间的连接,使得生成的图是连通的且没有环(即该图是一棵树)。

你可以自由地将连接点放置在电路板上的任何位置,并焊接它们之间的连接,使得没有两条连接相交(连接点处除外)。你订购的电路板相当大,因此不用担心空间不足。你的焊接技术非常精确,连接和连接点都可以被视为无穷小。

这本来非常简单,但你的老板坚持要求每条连接都必须是一条长度恰好为 $1\,\text{mm}$ 的直线(他说这是为了确保电子不必绕弯路,因为绕弯路会损害设计的效率)。

你很快意识到与他争论是徒劳的。你最快的脱身方法就是按照他的规格蚀刻出一份新设计。

输入格式

输入包含: 一行包含一个整数 $n$ ($2 \le n \le 1\,000$),表示连接点的数量。点编号从 $1$ 到 $n$。 $n - 1$ 行,每行包含两个整数 $a$ 和 $b$ ($1 \le a, b \le n$),描述 $a$ 和 $b$ 之间的一条连接。

保证这些边构成一棵合法的树。

输出格式

输出 $n$ 行,第 $i$ 行包含两个实数 $x_i, y_i$,表示点 $i$ 的坐标。为了使生产可行,需满足以下限制: 每对点之间的距离应至少为 $10^{-4}$。 每条边的长度应为 $1$,绝对误差不超过 $10^{-6}$。 不关联于同一个顶点的边之间的距离应至少为 $10^{-6}$。 坐标的绝对值不得超过 $3\,000$。

如果存在多个有效的解决方案,你可以输出其中任意一个。

样例

样例输入 1

5
1 2
1 3
1 4
1 5

样例输出 1

0.0000000 0.0000000
1.0000000 0.0000000
-1.0000000 0.0000000
0.0000000 1.0000000
0.0000000 -1.0000000

样例输入 2

5
2 1
3 1
2 4
2 5

样例输出 2

40 40
40.7071067812 40.7071067812
41 40
41.7071067812 40.7071067812
40 41.4142135624

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.