C. Circuit Board Design

Codeforces
IDCF10248C
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
More specifically, each circuit design consists of a number of connection points with some connections between them such that the resulting graph is connected and does not have any cycles (i.e., the graph is a tree). You are free to place the connection points anywhere on the circuit board and solder the connections between them so that no two connections intersect (except at the connection points). The boards you ordered are fairly large, so there is no danger of running out of space. You can solder so precisely that connections and connection points can be considered infinitesimal. This would all be very easy, however your boss persists that each connection needs to be a straight line of length exactly $1 " mm"$ (this is, so he says, to make sure the electrons do not have to travel around corners, which would be detrimental to the efficiency of the design). You soon realise that battling with him will be unsuccessful. Your quickest way out of this is to etch a new design according to his specifications. The input consists of: It is guaranteed that these edges describe a valid tree. Output $n$ lines, the $i$th of which contains two real numbers $x_i, y_i$, the coordinates of point $i$. To make the production feasible, the following restrictions apply: ## Input The input consists of: One line with one integer $n$ ($2 <= n <= 1 thin 000$), the number of connection points. The points are numbered from $1$ to $n$. $n -1$ lines, each with two integers $a$ and $b$ ($1 <= a, b <= n$), describing a connection between $a$ and $b$. It is guaranteed that these edges describe a valid tree. ## Output Output $n$ lines, the $i$th of which contains two real numbers $x_i, y_i$, the coordinates of point $i$. To make the production feasible, the following restrictions apply: The distance between each pair of points should be at least $10^(-4)$. The length of each edge should be $1$, up to an #cf_span(class=[tex-font-style-underline], body=[absolute]) error of at most $10^(-6)$. Edges that are not incident to the same vertex should be at least a distance $10^(-6)$ apart. The coordinates may not exceed an absolute value of $3 thin 000$. If there are multiple valid solutions, you may output any one of them. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of nations. Let $ T = (V, E) $ be a tree with $ V = \{1, 2, \dots, n\} $, where each edge $ (u, v) \in E $ has weight $ c_{u,v} \in \mathbb{Z}^+ $. For each nation $ i \in V $, let $ x_i \in \mathbb{Z}_{\geq 0} $ be the initial number of armies, and $ y_i \in \mathbb{Z}_{\geq 0} $ be the required final number of armies. Let $ d_i = x_i - y_i $ be the net surplus (if $ d_i > 0 $) or deficit (if $ d_i < 0 $) of armies at nation $ i $. **Constraints** 1. $ 1 \leq n \leq 250{,}000 $ 2. $ 1 \leq c_{u,v} \leq 10^6 $ for all edges $ (u,v) \in E $ 3. $ \sum_{i=1}^n x_i \geq \sum_{i=1}^n y_i $, and $ \sum_{i=1}^n x_i \leq 10^6 $ 4. $ \sum_{i=1}^n d_i = \sum_{i=1}^n (x_i - y_i) \geq 0 $ **Objective** Minimize the total transportation cost to move armies such that each nation $ i $ ends with at least $ y_i $ armies, where moving $ k $ armies across an edge of cost $ c $ incurs cost $ k \cdot c $. The movement must respect the tree structure and net surplus/deficit constraints. The minimum cost is the sum over all edges $ (u,v) \in E $ of $ c_{u,v} \cdot |f_{u,v}| $, where $ f_{u,v} $ is the net flow of armies across the edge (from the subtree side with surplus to the side with deficit), and the flow is determined by the subtree sum of $ d_i $.
API Response (JSON)
{
  "problem": {
    "name": "C. Circuit Board Design",
    "description": {
      "content": "More specifically, each circuit design consists of a number of connection points with some connections between them such that the resulting graph is connected and does not have any cycles (i.e., the g",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10248C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "More specifically, each circuit design consists of a number of connection points with some connections between them such that the resulting graph is connected and does not have any cycles (i.e., the g...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of nations.  \nLet $ T = (V, E) $ be a tree with $ V = \\{1, 2, \\dots, n\\} $, where each edge $ (u, v) \\in E $ has weight $ c_{u,v} \\in \\mathbb...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments