C. Property

Codeforces
IDCF852C
Time2000ms
Memory256MB
Difficulty
greedysortings
English · Original
Chinese · Translation
Formal · Original
Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on time, court decided to punish Bill by making him lose a part of his property. Bill’s property can be observed as a convex regular 2_n_\-sided polygon _A_0 _A_1... _A_2_n_ - 1 _A_2_n_,  _A_2_n_ =  _A_0, with sides of the exactly 1 meter in length. Court rules for removing part of his property are as follows: * Split every edge _A__k_ _A__k_ + 1,  _k_ = 0... 2_n_ - 1 in _n_ equal parts of size 1 / _n_ with points _P_0, _P_1, ..., _P__n_ - 1 * On every edge _A_2_k_ _A_2_k_ + 1,  _k_ = 0... _n_ - 1 court will choose one point _B_2_k_ =  _P__i_ for some _i_ = 0, ...,  _n_ - 1 such that * On every edge _A_2_k_ + 1_A_2_k_ + 2,  _k_ = 0..._n_ - 1 Bill will choose one point _B_2_k_ + 1 =  _P__i_ for some _i_ = 0, ...,  _n_ - 1 such that * Bill gets to keep property inside of 2_n_\-sided polygon _B_0 _B_1... _B_2_n_ - 1 Luckily, Bill found out which _B_2_k_ points the court chose. Even though he is a great mathematician, his house is very big and he has a hard time calculating. Therefore, he is asking you to help him choose points so he maximizes area of property he can keep. ## Input The first line contains one integer number _n_ (2 ≤ _n_ ≤ 50000), representing number of edges of 2_n_\-sided polygon. The second line contains _n_ distinct integer numbers _B_2_k_ (0 ≤ _B_2_k_ ≤ _n_ - 1,  _k_ = 0... _n_ - 1) separated by a single space, representing points the court chose. If _B_2_k_ = _i_, the court chose point _P__i_ on side _A_2_k_ _A_2_k_ + 1. ## Output Output contains _n_ distinct integers separated by a single space representing points _B_1, _B_3, ..., _B_2_n_ - 1 Bill should choose in order to maximize the property area. If there are multiple solutions that maximize the area, return any of them. [samples] ## Note To maximize area Bill should choose points: _B_1 = _P_0, _B_3 = _P_2, _B_5 = _P_1 ![image](https://espresso.codeforces.com/2f6820e290c879f16d07d79d039cecea64b7cbb8.png)
Bill 是 BubbleLand 著名的数学家。由于他革命性的数学发现,他赚到了足够的钱建造了一座漂亮的房子。但不幸的是,由于未按时缴纳房产税,法院决定惩罚 Bill,让他失去一部分财产。 Bill 的财产可以看作是一个凸的正 $2n$ 边形 $A_0 A_1 \dots A_{2n-1} A_{2n}, A_{2n} = A_0$,每条边的长度恰好为 1 米。 法院拆除部分财产的规则如下: 幸运的是,Bill 找到了法院选择的 $B_{2k}$ 点。尽管他是一位伟大的数学家,但他的房子非常大,计算起来很困难。因此,他请求你帮助他选择点,以便最大化他能保留的财产面积。 第一行包含一个整数 $n$($2 \leq n \leq 50000$),表示 $2n$ 边形的边数。 第二行包含 $n$ 个互不相同的整数 $B_{2k}$($0 \leq B_{2k} \leq n-1, k = 0 \dots n-1$),用单个空格分隔,表示法院选择的点。如果 $B_{2k} = i$,则法院在边 $A_{2k} A_{2k+1}$ 上选择了点 $P_i$。 输出包含 $n$ 个互不相同的整数,用单个空格分隔,表示 Bill 应选择的点 $B_1, B_3, \dots, B_{2n-1}$,以最大化财产面积。如果有多个方案能最大化面积,返回任意一个即可。 为了最大化面积,Bill 应选择点:$B_1 = P_0$, $B_3 = P_2$, $B_5 = P_1$ ## Input 第一行包含一个整数 $n$($2 \leq n \leq 50000$),表示 $2n$ 边形的边数。第二行包含 $n$ 个互不相同的整数 $B_{2k}$($0 \leq B_{2k} \leq n-1, k = 0 \dots n-1$),用单个空格分隔,表示法院选择的点。如果 $B_{2k} = i$,则法院在边 $A_{2k} A_{2k+1}$ 上选择了点 $P_i$。 ## Output 输出包含 $n$ 个互不相同的整数,用单个空格分隔,表示 Bill 应选择的点 $B_1, B_3, \dots, B_{2n-1}$,以最大化财产面积。如果有多个方案能最大化面积,返回任意一个即可。 [samples] ## Note 为了最大化面积,Bill 应选择点:$B_1 = P_0$, $B_3 = P_2$, $B_5 = P_1$
**Definitions** Let $ n \in \mathbb{Z} $, $ 2 \leq n \leq 50000 $. Let $ P = \{P_0, P_1, \dots, P_{n-1}\} $ be the set of points on the even-indexed sides of a regular $ 2n $-gon with side length 1, where $ P_i $ lies on side $ A_{2i}A_{2i+1} $. Given: A set $ B_{\text{even}} = \{B_{2k} \mid k = 0, \dots, n-1\} \subseteq \{0, 1, \dots, n-1\} $, representing the chosen positions on even-indexed sides. **Constraints** - All $ B_{2k} $ are distinct integers in $ \{0, 1, \dots, n-1\} $. **Objective** Choose distinct positions $ B_{2k+1} \in \{0, 1, \dots, n-1\} \setminus B_{\text{even}} $ for $ k = 0, \dots, n-1 $, such that the area of the polygon formed by vertices $ A_0, B_1, A_2, B_3, \dots, A_{2n-2}, B_{2n-1} $ is maximized. **Output** A permutation $ (B_1, B_3, \dots, B_{2n-1}) $ of the complement of $ B_{\text{even}} $ in $ \{0, 1, \dots, n-1\} $ that maximizes the area.
Samples
Input #1
3
0 1 2
Output #1
0 2 1
API Response (JSON)
{
  "problem": {
    "name": "C. Property",
    "description": {
      "content": "Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on ti",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF852C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Bill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on ti...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Bill 是 BubbleLand 著名的数学家。由于他革命性的数学发现,他赚到了足够的钱建造了一座漂亮的房子。但不幸的是,由于未按时缴纳房产税,法院决定惩罚 Bill,让他失去一部分财产。\n\nBill 的财产可以看作是一个凸的正 $2n$ 边形 $A_0 A_1 \\dots A_{2n-1} A_{2n}, A_{2n} = A_0$,每条边的长度恰好为 1 米。\n\n法院拆除部分财产的规则如下:...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $, $ 2 \\leq n \\leq 50000 $.  \nLet $ P = \\{P_0, P_1, \\dots, P_{n-1}\\} $ be the set of points on the even-indexed sides of a regular $ 2n $-gon with side length ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments