QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#8864. 传球

Statistics

一群学生刚刚结束了数学课,正准备去上体育课。老师要求他们围成一个圆圈站好。经过几分钟在操场上的忙碌走动,他们终于站成了一个严格凸多边形。虽然他们可能并不完全在圆周上,但老师对至少能形成某种结构感到满意。

这组 $N$ 名学生中,男生和女生的人数均为偶数。他们将进行两两传球练习,因此老师必须将他们配对。老师会将男生与男生配对,女生与女生配对。

学校管理层决定解决学生体能下降的问题。因此,他们为传球练习实施了一项质量衡量标准,即在每一对学生之间进行一轮传球时,球所经过的总距离。请帮助老师以最大化该衡量标准的方式将学生配对。

输入格式

第一行包含学生人数 $N$。第二行包含一个长度为 $N$ 的字符串 $S$,描述了沿多边形周长排列的学生,字符“B”代表男生,“G”代表女生。接下来的 $N$ 行按字符串 $S$ 中描述的顺序,提供了学生的坐标 $X_i$ 和 $Y_i$(整数,以空格分隔)。

数据范围

  • $2 \le N \le 50$
  • 男生和女生的人数均为偶数。注意其中一方的人数可以为零。
  • 坐标 $X_i$ 和 $Y_i$ 的绝对值不超过 $10\,000$。

输出格式

输出通过适当配对学生所能获得的最大传球总距离。如果结果与标准答案的相对误差或绝对误差在 $10^{-6}$ 以内,则该解被视为正确。

样例

样例输入 1

4
BGBG
0 0
0 1
1 1
1 0

样例输出 1

2.828427125

样例输入 2

4
GGBB
0 0
0 1
1 1
1 0

样例输出 2

2

样例输入 3

12
GBGBBGBBBBGB
0 -15
6 -14
19 -5
17 7
11 12
1 15
-9 13
-15 10
-17 8
-19 4
-16 -9
-13 -11

样例输出 3

186.529031603

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.