F. Fair Distribution

Codeforces
IDCF10236F
Time1000ms
Memory1024MB
Difficulty
English · Original
Formal · Original
While wandering around the rural parts of Lalaland, Aram found himself in a backwards village so small that it wasn't named a number; instead, the village was named Lucca. The $N$ villagers of Lucca faced a dilemma. The government of Lalaland decided to build a dam that would flood all of Lucca, and paid the town a lump sum to compensate for the land and relocation costs. Following Lalaland tradition, the lump sum was set to the area of the union of all polygons whose vertices are a subset of the villagers' homes, also known as the area of the convex hull of the villagers' homes. Unfortunately, there were no clear instructions on how to distribute the money. Yrneh, who lived on the edge of village, demanded a larger share because his house alone increased the size of the lump sum. Leinad, who lived near Yrneh, complained that even if Yrneh wasn't there, his location ensured that the lump sum would be about the same. Accul, who lived near the center of the village, demanded at least some fraction of the lump sum, at least for relocation since his home would also be destroyed. Aram, appalled by the uncivilized nature of the discussion in the backwards village, decided to step in and help before it came to blows. He devised a brilliant solution. He would consider the villagers in a random order, given by a permutation $p$. Then, for each $i$, he would calculate $A_i$, the traditional lump sum using only the homes of $p_1, p_2, \\dots p_i$. For increasing the sum, the villager $p_i$ would receive exactly their contribution $A_i -A_{i -1}$. Yrneh complained that if he were unlucky enough to be considered first, he would get nothing. Aram thought for a bit and realized it would be more fair to take the expected value under this scheme, treating all $N!$ permutations as equally likely. He explained, using Lalaland's most sophisticated mathematics, that the total payout to the villagers would exactly equal the original lump sum. This solution seems to have pleased everyone, so they turned to Aram to actually compute the amount of money each person would get. This is too much for Aram to compute by hand, so he needs your help! The first line contains $N$ ($1 <= N <= 200$), the number of villagers. Then follow $N$ lines, the $i$th of which contains two space separated integers $x_i$ and $y_i$ ($-10 thin 000 <= x_i, y_i <= 10 thin 000$), indicating the planar coordinates of a point representing villager $i$'s house. Homes are so small they can be treated as points. No two villagers have their homes at the exact same coordinates because all of them are single. Output $N$ lines. On line $i$, output the amount of money villager $i$ would get, as a floating-point number. If the exact answer is $x$, your answer $y$ will be accepted if $frac(| y -x |, max (x , thin 1)) < 10^(-6)$. ## Input The first line contains $N$ ($1 <= N <= 200$), the number of villagers.Then follow $N$ lines, the $i$th of which contains two space separated integers $x_i$ and $y_i$ ($-10 thin 000 <= x_i, y_i <= 10 thin 000$), indicating the planar coordinates of a point representing villager $i$'s house. Homes are so small they can be treated as points. No two villagers have their homes at the exact same coordinates because all of them are single. ## Output Output $N$ lines. On line $i$, output the amount of money villager $i$ would get, as a floating-point number.If the exact answer is $x$, your answer $y$ will be accepted if $frac(| y -x |, max (x comma thin 1)) < 10^(-6)$. [samples]
**Definitions** Let $ N \in \mathbb{Z}^+ $, $ N \leq 200 $. Let $ P = \{ p_1, p_2, \dots, p_N \} \subset \mathbb{R}^2 $ be a set of $ N $ distinct points in the plane, where $ p_i = (x_i, y_i) $. Let $ \text{CH}(S) $ denote the convex hull of a finite set $ S \subset \mathbb{R}^2 $, and $ \text{Area}(S) $ denote the area of $ \text{CH}(S) $. Let $ \mathcal{S}_N $ be the set of all $ N! $ permutations of $ \{1, 2, \dots, N\} $. For a permutation $ \pi \in \mathcal{S}_N $, define: - $ S_i^\pi = \{ p_{\pi(1)}, p_{\pi(2)}, \dots, p_{\pi(i)} \} $, - $ A_i^\pi = \text{Area}(S_i^\pi) $, - The contribution of villager $ \pi(i) $ under $ \pi $ is $ C_i^\pi = A_i^\pi - A_{i-1}^\pi $, with $ A_0^\pi = 0 $. **Constraints** 1. $ 1 \leq N \leq 200 $ 2. $ -10000 \leq x_i, y_i \leq 10000 $ for all $ i \in \{1, \dots, N\} $ 3. All $ p_i $ are distinct. **Objective** For each villager $ j \in \{1, \dots, N\} $, compute the expected contribution: $$ E_j = \frac{1}{N!} \sum_{\pi \in \mathcal{S}_N} C_j^\pi $$ where $ C_j^\pi $ is the contribution of villager $ j $ under permutation $ \pi $, i.e., if $ \pi(k) = j $, then $ C_j^\pi = A_k^\pi - A_{k-1}^\pi $. Output $ E_1, E_2, \dots, E_N $, each as a floating-point number.
API Response (JSON)
{
  "problem": {
    "name": "F. Fair Distribution",
    "description": {
      "content": "While wandering around the rural parts of Lalaland, Aram found himself in a backwards village so small that it wasn't named a number; instead, the village was named Lucca. The $N$ villagers of Lucca ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 1048576
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10236F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "While wandering around the rural parts of Lalaland, Aram found himself in a backwards village so small that it wasn't named a number; instead, the village was named Lucca.\n\nThe $N$ villagers of Lucca ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $, $ N \\leq 200 $.  \nLet $ P = \\{ p_1, p_2, \\dots, p_N \\} \\subset \\mathbb{R}^2 $ be a set of $ N $ distinct points in the plane, where $ p_i = (x_i, y_i) $. ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments