CF2172C.Circles Are Far from Each Other
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n circles and two integer parameters k and ℓ. The i-th circle has radius ri and ri≥rj holds for every 1≤i<j≤n. The task is to draw these n circles on a 2D plane so that the following conditions are simultaneously satisfied. Before proceeding to the conditions, let us recall that:
- Each circle is uniquely determined by its center O and radius r.
- A circle of radius r is defined as the set of all points whose distance from its center O is exactly r. All distances considered in this task are Euclidean.
- The interior region of a circle is defined as the set of all points whose distance from its center O is less than r.
- We say that one circle C encloses another circle C′ if all points of C′ lie inside the interior region of C.
You need to draw these n circles to satisfy all of the following conditions:
-
The centers of all circles are collinear.
-
The distance between any two centers is at most k.
-
No two circles intersect.
-
If a circle encloses two circles C and C′, then either C encloses C′ or C′ encloses C.
-
The first ℓ circles may or may not be enclosed by other circles, whereas each of the remaining n−ℓ circles must be enclosed by at least one circle.
An arrangement that satisfies all the above conditions is called feasible. For a feasible arrangement A, define its quality d(A) as the minimum distance between any two points belonging to different circles.
If there exists at least one feasible arrangement for the given case, output the maximum possible quality among all feasible arrangements. If no feasible arrangements exist, output 0.
A feasible arrangement for sample input 1.
An arrangement that is not feasible for sample input 1.
给你 n 个圆,以及两个整数参数 k 和 ℓ。第 i 个圆的半径为 ri,且对任意 1≤i<j≤n 均满足 ri≥rj。你的任务是在二维平面上绘制这 n 个圆,使得以下所有条件同时成立。在列出这些条件之前,我们先回顾如下定义:
- 每个圆由其中心 O 和半径 r 唯一确定。
- 半径为 r 的圆定义为所有到其中心 O 的距离恰好等于 r 的点构成的集合。本题中所有涉及的距离均为欧几里得距离。
- 圆的内部区域定义为所有到其中心 O 的距离严格小于 r 的点构成的集合。
- 若圆 C 的内部区域包含圆 C′ 的所有点,则称圆 C 包围(encloses)圆 C′。
你需要绘制这 n 个圆,使其满足以下全部条件:
- 所有圆的中心共线。
- 任意两个中心之间的距离至多为 k。
- 任意两个圆互不相交。
- 若某圆包围了两个圆 C 和 C′,则要么 C 包围 C′,要么 C′ 包围 C。
- 前 ℓ 个圆可以被其他圆包围,也可以不被包围;而其余 n−ℓ 个圆中的每一个都必须至少被一个圆包围。
满足上述所有条件的构型称为可行构型(feasible arrangement)。对于一个可行构型 A,定义其质量(quality)d(A) 为:属于不同圆的任意两点之间的最小距离。
若给定输入存在至少一个可行构型,则输出所有可行构型中可能达到的最大质量;若不存在任何可行构型,则输出 0。
样例输入 1 的一个可行构型。
样例输入 1 的一个不可行构型。
输入格式
The first line contains three integers k, n, and ℓ, representing the maximum distance between centers, the number of circles to be drawn, and the number of circles that may or may not be enclosed by other circles, respectively.
The second line contains n integers r1,r2,…,rn, where ri is the radius of the i-th circle.
- 1≤k≤109
- 2≤n≤105
- 1≤ℓ≤minn,200
- 1≤ri≤109
- ri≥rj for every 1≤i<j≤n.
第一行包含三个整数 k、n 和 ℓ,分别表示圆心之间的最大距离、需要绘制的圆的数量,以及可能被其他圆包含或不被包含的圆的数量。
第二行包含 n 个整数 r1,r2,…,rn,其中 ri 表示第 i 个圆的半径。
- 1≤k≤109
- 2≤n≤105
- 1≤ℓ≤minn,200
- 1≤ri≤109
- 对于所有 1≤i<j≤n,均有 ri≥rj。
输出格式
If no feasible arrangements exist, output a single integer 0.
Otherwise, output the maximum possible quality d(A) among all feasible arrangements A in the following format:
- If d(A) is an integer, output it as a single integer.
- If d(A) is not an integer, output it in the rational form a/b such that 1≤a,b≤109, gcd(a,b)=1, and ∣d(A)−a/b∣ is minimized. If multiple such forms satisfy the constraints, print any.
如果不存在可行的安排方案,则输出单个整数 0。
否则,输出所有可行安排 A 中最大的可能质量 d(A),格式如下:
- 若 d(A) 为整数,则直接输出该整数;
- 若 d(A) 不是整数,则以最简分数形式 a/b 输出,其中 1≤a,b≤109,gcd(a,b)=1,且 ∣d(A)−a/b∣ 最小。若存在多个满足条件的分数形式,输出任意一个即可。
输入输出样例
输入#1
15 4 3 7 5 3 1
输出#1
3
输入#2
14 6 1 7 5 4 3 2 1
输出#2
1
输入#3
14 2 2 5 4
输出#3
5
输入#4
22 4 4 4 4 1 1
输出#4
10/3
输入#5
13 3 3 6 3 1
输出#5
4
说明/提示
Explanation of Example 1: A feasible arrangement is illustrated in the first figure, where each circle and its center are shown in a unique color.
In this arrangement, the minimum distance between any two points belonging to different circles is 3, and the two points witnessing this distance are marked as red dots. Hence, the quality of this arrangement is 3, which is the maximum possible among all feasible arrangements for this case. Note that only circle 4 is required to be enclosed within another circle, while the remaining circles may or may not be enclosed.
The second figure shows an arrangement that is not feasible. In this case, circle 1 encloses both circle 3 and circle 4, but neither of these two circles encloses the other, thereby violating condition 4.
示例 1 的说明:第一个图中展示了一种可行的排列方式,其中每个圆及其圆心均以唯一颜色标出。
在此排列中,属于不同圆的任意两点之间的最小距离为 3,且实现该最小距离的两个点以红色圆点标出。因此,该排列的质量为 3,是本例所有可行排列中所能达到的最大值。注意:仅要求圆 4 必须被另一个圆所包含,其余各圆则可包含也可不包含于其他圆内。
第二个图展示了一种不可行的排列方式。此时,圆 1 同时包含了圆 3 和圆 4,但这两个圆彼此之间互不包含,从而违反了条件 4。
输入解题思路,AI测评打分。不知道怎么写?