I. Polycarp and Heat Exchangers

Codeforces
IDCF10083I
Time2000ms
Memory512MB
Difficulty
English · Original
Formal · Original
Polycarp does experiments again. He has N triangle heat exchangers on the field. Each i-th heat exchanger has input and output and their coefficients kini and kouti respectively. If two heat exchangers intersect (or first one touches second one), then thir inputs becamee molten together and their input coefficient became k, where , k1 and k2 are input coefficients of heat exchangers. Each point of field emits heat, heat comes out with specific speed. If this point is beneath some heat exchangers, it's value is multiplied by final value of their input coefficient and then it's multiplied by their output coefficients. Square of field with sides's length 1 emits 1 unit of heat. Polycarp wants to know value of heat per second, which emits all heat exchangers. The first line contains N, 1 ≤ N ≤ 10. N lines follow, each containing x1i, y1i, x2i, y2i, x3i, y3i, kini, kouti — coordinates of vertexes i-th heat exchanger, input and output coefficients. All numbers are separated by space, coordinates are integers, which are lesser than 101 and greater than  - 101, 0.1 ≤ kini, kouti ≤ 2.0. Triangles are not degenerate. Output summary value of heat per second, which emits all heat exchangers. You may assume that answers is coparated with the precision of 10 - 4. ## Input The first line contains N, 1 ≤ N ≤ 10. N lines follow, each containing x1i, y1i, x2i, y2i, x3i, y3i, kini, kouti — coordinates of vertexes i-th heat exchanger, input and output coefficients. All numbers are separated by space, coordinates are integers, which are lesser than 101 and greater than  - 101, 0.1 ≤ kini, kouti ≤ 2.0. Triangles are not degenerate. ## Output Output summary value of heat per second, which emits all heat exchangers. You may assume that answers is coparated with the precision of 10 - 4. [samples]
**Definitions** Let $ N \in \mathbb{Z} $, $ 1 \leq N \leq 10 $, be the number of triangular heat exchangers. For each $ i \in \{1, \dots, N\} $: - Let $ T_i \subset \mathbb{R}^2 $ be a non-degenerate triangle with vertices $ (x_{i1}, y_{i1}), (x_{i2}, y_{i2}), (x_{i3}, y_{i3}) $. - Let $ k_{\text{in},i} \in \mathbb{R} $, $ 0.1 \leq k_{\text{in},i} \leq 2.0 $, be the input coefficient. - Let $ k_{\text{out},i} \in \mathbb{R} $, $ 0.1 \leq k_{\text{out},i} \leq 2.0 $, be the output coefficient. Let $ \mathcal{I} \subseteq \{1, \dots, N\} $ be a maximal set of mutually intersecting (including touching) triangles. For each such $ \mathcal{I} $, define the merged input coefficient: $$ k_{\text{in}}^{\mathcal{I}} = \prod_{i \in \mathcal{I}} k_{\text{in},i} $$ Each triangle $ i \in \mathcal{I} $ contributes output coefficient $ k_{\text{out},i} $ independently. Let $ A_i = \text{Area}(T_i) $ be the area of triangle $ T_i $. Let $ \mathcal{P} \subset \mathbb{R}^2 $ be the union of all triangles $ T_i $, $ i = 1, \dots, N $. **Constraints** 1. Coordinates are integers: $ -100 < x_{ij}, y_{ij} < 100 $. 2. Triangles are non-degenerate. 3. Heat emission rate per unit area is 1 unit per second on the base field. **Objective** Compute the total heat emission per second: $$ H = \sum_{\mathcal{I} \in \mathcal{C}} \left( k_{\text{in}}^{\mathcal{I}} \cdot \sum_{i \in \mathcal{I}} k_{\text{out},i} \cdot A_i \right) $$ where $ \mathcal{C} $ is the set of all connected components (maximal intersecting groups) of triangles.
API Response (JSON)
{
  "problem": {
    "name": "I. Polycarp and Heat Exchangers",
    "description": {
      "content": "Polycarp does experiments again. He has N triangle heat exchangers on the field. Each i-th heat exchanger has input and output and their coefficients kini and kouti respectively. If two heat exchanger",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10083I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Polycarp does experiments again. He has N triangle heat exchangers on the field. Each i-th heat exchanger has input and output and their coefficients kini and kouti respectively. If two heat exchanger...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z} $, $ 1 \\leq N \\leq 10 $, be the number of triangular heat exchangers.  \nFor each $ i \\in \\{1, \\dots, N\\} $:  \n- Let $ T_i \\subset \\mathbb{R}^2 $ be a non-degen...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments