← All problemsSign in

Embedding a Tree (Challenge)

CodeChefRating 3628Open on judge ↗

You are given a tree with N nodes. You should embed this tree in a 2-D plane such that each node of the tree is located at a point with integer coordinates. Let's denote the coordinates of the i-th node by pi = (xi, yi). An edge between nodes u and v corresponds to a line segment between points pu and pv. Formally, the mapping of the nodes to points should satisfy the following property: No two

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start