CF1252I.Mission Possible

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Allen, a government secret service, has been assigned to infiltrate a mafia secret base to uncover crucial information regarding the mafia's operations.

The secret base is a rectangular bounded by (xL,yL)(x_L,y_L), (xL,yR)(x_L,y_R), (xR,yL)(x_R,y_L), and (xR,yR)(x_R,y_R) in a Cartesian coordinate system where xL<xRx_L \lt x_R and yL<yRy_L \lt y_R. There are NN sensors placed inside the secret base. The ithi^{th} sensor is located at (xi,yi)(x_i, y_i) and has an effective sensing radius of rir_i which can detect any person who is strictly within the radius of rir_i from (xi,yi)(x_i, y_i). In other words, the ithi^{th} sensor can detect a person at location (xa,ya)(x_a, y_a) if and only if the Euclidean distance of (xi,yi)(x_i, y_i) and (xa,ya)(x_a, y_a) is strictly less than rir_i. It is also known that the Euclidean distance of any two sensors ii and jj is strictly larger than ri+rjr_i + r_j. Note that the Euclidean distance of two points, (xa,ya)(x_a, y_a) and (xb,yb)(x_b, y_b), is ∣xa−xb∣2+∣ya−yb∣2\sqrt{|x_a - x_b|^2 + |y_a - y_b|^2}.

Allen begins his infiltration mission at location (xs,ys)(x_s, y_s), and his target is located at (xt,yt)(x_t, y_t). Allen has the power to run extremely fast in a straight line while he needs to spend extra time to change his running trajectory (to adjust his footing). Although he is a fast runner, he still needs to make sure that none of the sensors detect him while he is running, i.e. there is no point in his running trajectory which is strictly within a sensor effective sensing radius.

Let P=(xp1,yp1),…,(xp∣P∣,yp∣P∣)P = {(x_{p_1}, y_{p_1}), \dots, (x_{p_{|P|}}, y_{p_{|P|}})} be the set of locations where Allen changes his running trajectory, thus, Allen's running trajectory with PP is (xs,ys)→(xp1,yp1)→⋯→(xp∣P∣,yp∣P∣)→(xt,yt)(x_s, y_s) \rightarrow (x_{p_1}, y_{p_1}) \rightarrow \dots \rightarrow (x_{p_{|P|}}, y_{p_{|P|}}) \rightarrow (x_t, y_t) where (xa,ya)→(xb,yb)(x_a,y_a) \rightarrow (x_b,y_b) implies that Allen is running from (xa,ya)(x_a,y_a) to (xb,yb)(x_b,y_b) in a straight line. The set PP is feasible if and only if with PP, Allen is not detected by any sensor and is not running out of the secret base (although, Allen is allowed to run along the secret base perimeter). Note that xpx_p and ypy_p, (xp,yp)∈P(x_p,y_p) \in P, are not necessarily integers; they can be real numbers.

Your task in this problem is to find any one feasible PP which contains no more than 10001000 points.

艾伦是一名政府秘密特工,被指派潜入一个黑手党秘密基地,以获取有关该黑手党组织运作的关键情报。

该秘密基地是一个矩形区域,其四个顶点在笛卡尔坐标系中分别为 (xL,yL)(x_L,y_L)、(xL,yR)(x_L,y_R)、(xR,yL)(x_R,y_L) 和 (xR,yR)(x_R,y_R),其中 xL<xRx_L \lt x_R 且 yL<yRy_L \lt y_R。基地内部共部署了 NN 个传感器。第 ii 个传感器位于 (xi,yi)(x_i, y_i),其有效感知半径为 rir_i,可探测到严格位于以 (xi,yi)(x_i, y_i) 为中心、半径为 rir_i 的开圆盘内的任何人。换言之,当且仅当点 (xi,yi)(x_i, y_i) 与 (xa,ya)(x_a, y_a) 之间的欧几里得距离严格小于 rir_i 时,第 ii 个传感器才能探测到位于 (xa,ya)(x_a, y_a) 处的人员。已知:任意两个传感器 ii 与 jj 之间的欧几里得距离严格大于 ri+rjr_i + r_j。注意,两点 (xa,ya)(x_a, y_a) 与 (xb,yb)(x_b, y_b) 之间的欧几里得距离定义为 ∣xa−xb∣2+∣ya−yb∣2\sqrt{|x_a - x_b|^2 + |y_a - y_b|^2}。

艾伦从起点 (xs,ys)(x_s, y_s) 开始执行潜入任务,其目标位置为 (xt,yt)(x_t, y_t)。他具备沿直线极速奔跑的能力,但每次改变运动轨迹(例如调整步伐)都需要额外耗时。尽管奔跑速度极快,他仍必须确保在整段行进过程中不被任何传感器探测到——即其运动轨迹上不存在任何一点严格处于任一传感器的有效感知半径之内。

令 P={(xp1,yp1),…,(xp∣P∣,yp∣P∣)}P = \{(x_{p_1}, y_{p_1}), \dots, (x_{p_{|P|}}, y_{p_{|P|}})\} 表示艾伦改变运动轨迹的位置集合,则其完整运动路径为

(xs,ys)→(xp1,yp1)→⋯→(xp∣P∣,yp∣P∣)→(xt,yt),(x_s, y_s) \rightarrow (x_{p_1}, y_{p_1}) \rightarrow \dots \rightarrow (x_{p_{|P|}}, y_{p_{|P|}}) \rightarrow (x_t, y_t),

其中符号 (xa,ya)→(xb,yb)(x_a,y_a) \rightarrow (x_b,y_b) 表示艾伦沿直线从 (xa,ya)(x_a,y_a) 奔跑至 (xb,yb)(x_b,y_b)。集合 PP 是可行的,当且仅当:采用该路径时,艾伦既未被任何传感器探测到,也未跑出秘密基地边界(但允许沿基地周界边缘奔跑)。注意:对任意 (xp,yp)∈P(x_p,y_p) \in P,其坐标 xpx_p 与 ypy_p 不必为整数,可以是任意实数。

本题要求:找出任意一个可行的 PP,且满足 ∣P∣≤1000|P| \le 1000。

输入格式

Input begins with a line containing five integers: NN xLx_L yLy_L xRx_R yRy_R (0≤N≤500 \le N \le 50; 0≤xL<xR≤10000 \le x_L \lt x_R \le 1000; 0≤yL<yR≤10000 \le y_L \lt y_R \le 1000) representing the number of sensors and the secret base (xLx_L, yLy_L, xRx_R, yRy_R), respectively. The next line contains two integers: xsx_s ysy_s (xL<xs<xRx_L \lt x_s \lt x_R; yL<ys<yRy_L \lt y_s \lt y_R) representing Allen's initial location. The next line contains two integers: xtx_t yty_t (xL<xt<xRx_L \lt x_t \lt x_R; yL<yt<yRy_L \lt y_t \lt y_R) representing Allen's target location. It is guaranteed that xs≠xtx_s \ne x_t or ys≠yty_s \ne y_t. The next NN lines each contains three integers: xix_i yiy_i rir_i (xL<xi−ri<xi+ri<xRx_L \lt x_i - r_i \lt x_i + r_i \lt x_R; yL<yi−ri<yi+ri<yRy_L \lt y_i - r_i \lt y_i + r_i \lt y_R; 1≤ri≤10001 \le r_i \le 1000) representing a sensor at location (xi,yi)(x_i, y_i) with an effective sensing radius of rir_i. It is guaranteed that the Euclidean distance of any two sensors ii and jj is larger than ri+rjr_i + r_j. It is also guaranteed that the Euclidean distance of (xs,ys)(x_s,y_s) and (xt,yt)(x_t,y_t) to any sensor ii is larger than rir_i.

输入的第一行包含五个整数:NN xLx_L yLy_L xRx_R yRy_R(其中 0≤N≤500 \le N \le 50;0≤xL<xR≤10000 \le x_L \lt x_R \le 1000;0≤yL<yR≤10000 \le y_L \lt y_R \le 1000),分别表示传感器的数量以及秘密基地的边界坐标 (xL,yL,xR,yR)(x_L, y_L, x_R, y_R)。
第二行包含两个整数:xsx_s ysy_s(满足 xL<xs<xRx_L \lt x_s \lt x_R 且 yL<ys<yRy_L \lt y_s \lt y_R),表示艾伦的初始位置。
第三行包含两个整数:xtx_t yty_t(满足 xL<xt<xRx_L \lt x_t \lt x_R 且 yL<yt<yRy_L \lt y_t \lt y_R),表示艾伦的目标位置。
保证 xs≠xtx_s \ne x_t 或 ys≠yty_s \ne y_t。
接下来的 NN 行,每行包含三个整数:xix_i yiy_i rir_i(满足 xL<xi−ri<xi+ri<xRx_L \lt x_i - r_i \lt x_i + r_i \lt x_R;yL<yi−ri<yi+ri<yRy_L \lt y_i - r_i \lt y_i + r_i \lt y_R;1≤ri≤10001 \le r_i \le 1000),表示位于 (xi,yi)(x_i, y_i) 处、有效感知半径为 rir_i 的一个传感器。
保证任意两个传感器 ii 和 jj 之间的欧几里得距离大于 ri+rjr_i + r_j。
还保证初始点 (xs,ys)(x_s,y_s) 和目标点 (xt,yt)(x_t,y_t) 到任一传感器 ii 的欧几里得距离均大于 rir_i。

输出格式

Output in a line an integer representing the size of a feasible PP. The next ∣P∣|P| lines each contains two real numbers (separated by a single space); the jthj^{th} line contains xjx_j yjy_j representing the jthj^{th} point in PP. You may output any feasible PP with no more than 10001000 points.

Due to the nature of the output (floating point), let us define an epsilon ϵ\epsilon to be 10−610^{-6} to verify the output. Consider Q1=(xs,ys)Q_1 = (x_s, y_s), Qj+1=PjQ_{j+1} = P_j for all 1≤j≤∣P∣1 \le j \le |P|, and Q∣P∣+2=(xt,yt)Q_{|P|+2} = (x_t, y_t). Then, PP is considered correct if and only if PP contains no more than 10001000 points and all of the following are satisfied:

  • xL−ϵ≤xpk≤xR+ϵx_L - \epsilon \le x_{p_k} \le x_R + \epsilon and yL−ϵ≤ypk≤yR+ϵy_L - \epsilon \le y_{p_k} \le y_R + \epsilon for all 1≤k≤∣P∣1 \le k \le |P| (Allen is not running out of the secret base).
  • For all 1≤k<∣Q∣1 \le k \lt |Q|, let SkS_k be the line segment connecting QkQ_k and Qk+1Q_{k+1} (Allen is running in straight line). For all 1≤i≤N1 \le i \le N, let (xk,i,yk,i)(x_{k,i},y_{k,i}) be the point along SkS_k that is the closest to the ithi^{th} sensor's location, (xi,yi)(x_i,y_i). Let dk,id_{k,i} be the Euclidean distance between (xk,i,yk,i)(x_{k,i},y_{k,i}) and (xi,yi)(x_i,y_i). Then, the constraint ri≤dk,i+ϵr_i \le d_{k,i} + \epsilon should be satisfied (Allen is not detected by any sensor).
  • All points in QQ are distinct. Two points, (xa,ya)(x_a,y_a) and (xb,yb)(x_b,y_b), are considered distinct if and only if ∣xa−xb∣>ϵ|x_a - x_b| \gt \epsilon or ∣ya−yb∣>ϵ|y_a - y_b| \gt \epsilon.

在一行中输出一个整数,表示可行解 PP 的大小(即点的数量)。接下来的 ∣P∣|P| 行每行包含两个实数(以单个空格分隔);第 jj 行包含 xjx_j 和 yjy_j,表示 PP 中的第 jj 个点。你可以输出任意一个满足条件的 PP,且其点数不超过 10001000。

由于输出涉及浮点数,我们定义容差 ϵ=10−6\epsilon = 10^{-6} 用于验证输出正确性。令 Q1=(xs,ys)Q_1 = (x_s, y_s),对所有 1≤j≤∣P∣1 \le j \le |P| 有 Qj+1=PjQ_{j+1} = P_j,且 Q∣P∣+2=(xt,yt)Q_{|P|+2} = (x_t, y_t)。则 PP 被视为正确当且仅当:PP 所含点数不超过 10001000,且以下所有条件均满足:

  • 对所有 1≤k≤∣P∣1 \le k \le |P|,满足 xL−ϵ≤xpk≤xR+ϵx_L - \epsilon \le x_{p_k} \le x_R + \epsilon 且 yL−ϵ≤ypk≤yR+ϵy_L - \epsilon \le y_{p_k} \le y_R + \epsilon(Allen 未跑出秘密基地边界)。
  • 对所有 1≤k<∣Q∣1 \le k < |Q|,令 SkS_k 为连接 QkQ_k 与 Qk+1Q_{k+1} 的线段(Allen 沿直线奔跑)。对所有 1≤i≤N1 \le i \le N,令 (xk,i,yk,i)(x_{k,i},y_{k,i}) 为线段 SkS_k 上距离第 ii 个传感器位置 (xi,yi)(x_i,y_i) 最近的点;令 dk,id_{k,i} 为 (xk,i,yk,i)(x_{k,i},y_{k,i}) 与 (xi,yi)(x_i,y_i) 之间的欧氏距离。则需满足约束 ri≤dk,i+ϵr_i \le d_{k,i} + \epsilon(Allen 未被任何传感器探测到)。
  • QQ 中所有点互异。两点 (xa,ya)(x_a,y_a) 与 (xb,yb)(x_b,y_b) 被视为互异当且仅当 ∣xa−xb∣>ϵ|x_a - x_b| > \epsilon 或 ∣ya−yb∣>ϵ|y_a - y_b| > \epsilon。

输入输出样例

  • 输入#1

    3 2 2 50 26
    4 14
    48 14
    15 13 7
    36 16 6
    46 18 3

    输出#1

    2
    13.25 23.1234567
    36.591003 7.1
  • 输入#2

    1 0 0 1000 1000
    100 501
    900 501
    500 251 250

    输出#2

    0

说明/提示

Explanation for the sample input/output #1

The figure above shows the PP from the sample output. Note that there exists a feasible PP with only one point in this sample, although you are not required to find such PP.

样例输入/输出 #1 的说明

上图展示了样例输出中的集合 PP。注意:在该样例中,存在一个仅含一个点的可行集合 PP,但你无需找出这样的 PP。

输入解题思路,AI测评打分。不知道怎么写?

首页