CF989E.A Trance of Nightfall

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The cool breeze blows gently, the flowing water ripples steadily.

"Flowing and passing like this, the water isn't gone ultimately; Waxing and waning like that, the moon doesn't shrink or grow eventually."

"Everything is transient in a way and perennial in another."

Kanno doesn't seem to make much sense out of Mino's isolated words, but maybe it's time that they enjoy the gentle breeze and the night sky — the inexhaustible gifts from nature.

Gazing into the sky of stars, Kanno indulges in a night's tranquil dreams.

There is a set SS of nn points on a coordinate plane.

Kanno starts from a point PP that can be chosen on the plane. PP is not added to SS if it doesn't belong to SS. Then the following sequence of operations (altogether called a move) is repeated several times, in the given order:

  1. Choose a line ll such that it passes through at least two elements in SS and passes through Kanno's current position. If there are multiple such lines, one is chosen equiprobably.
  2. Move to one of the points that belong to SS and lie on ll. The destination is chosen equiprobably among all possible ones, including Kanno's current position (if it does belong to SS).

There are qq queries each consisting of two integers (ti,mi)(t_i, m_i). For each query, you're to help Kanno maximize the probability of the stopping position being the tit_i-th element in SS after mim_i moves with a proper selection of PP, and output this maximum probability. Note that according to rule 1, PP should belong to at least one line that passes through at least two points from SS.

凉爽的微风轻轻吹拂,潺潺流水缓缓泛起涟漪。

“逝者如斯,而未尝往也;盈虚者如彼,而卒莫消长也。”

“万物皆有其暂存之相,亦有其恒常之性。”

贯野难以从美浓这零散的言语中领悟深意,但或许此刻正该静享这和煦微风与浩瀚夜空——大自然取之不竭的馈赠。

仰望繁星点点的夜空,贯野沉醉于一晚宁静的梦境之中。

平面上给定一个包含 nn 个点的集合 SS。

贯野从平面上任选一点 PP 出发(若 P∉SP \notin S,则不将其加入 SS)。随后,按如下顺序重复执行以下一系列操作(统称为一次“移动”)若干次:

  1. 选择一条直线 ll,使得 ll 至少经过 SS 中两个点,且经过贯野当前所在位置。若满足条件的直线有多条,则等概率地从中任选一条。
  2. 移动至 ll 上属于 SS 的某一点。所有可能的目的地点(包括贯野当前所在位置,若其本身属于 SS)被等概率地选为终点。

共有 qq 个询问,每个询问由两个整数 (ti,mi)(t_i, m_i) 构成。对每个询问,你需要帮助贯野选择适当的初始点 PP,以最大化经过 mim_i 次移动后停在 SS 中第 tit_i 个点的概率,并输出该最大概率。注意:根据规则 1,所选初始点 PP 必须至少位于一条经过 SS 中至少两个点的直线上。

输入格式

The first line contains a positive integer nn (2≤n≤2002 \leq n \leq 200) — the number of points in SS.

The ii-th of the following nn lines contains two space-separated integers xix_i and yiy_i (−104≤xi,yi≤104-10^4 \leq x_i, y_i \leq 10^4) — the coordinates of the ii-th point in SS. The input guarantees that for all 1≤i<j≤n1 \leq i \lt j \leq n, (xi,yi)≠(xj,yj)(x_i, y_i) \neq (x_j, y_j) holds.

The next line contains a positive integer qq (1≤q≤2001 \leq q \leq 200) — the number of queries.

Each of the following qq lines contains two space-separated integers tt and mm (1≤ti≤n1 \leq t_i \leq n, 1≤mi≤1041 \leq m_i \leq 10^4) — the index of the target point and the number of moves, respectively.

第一行包含一个正整数 nn(2≤n≤2002 \leq n \leq 200)——集合 SS 中点的个数。

接下来的 nn 行中,第 ii 行包含两个用空格分隔的整数 xix_i 和 yiy_i(−104≤xi,yi≤104-10^4 \leq x_i, y_i \leq 10^4)——表示集合 SS 中第 ii 个点的坐标。输入保证对所有满足 1≤i<j≤n1 \leq i \lt j \leq n 的 i,ji,j,均有 (xi,yi)≠(xj,yj)(x_i, y_i) \neq (x_j, y_j)。

下一行包含一个正整数 qq(1≤q≤2001 \leq q \leq 200)——查询的个数。

接下来的 qq 行中,每行包含两个用空格分隔的整数 tt 和 mm(1≤ti≤n1 \leq t_i \leq n,1≤mi≤1041 \leq m_i \leq 10^4)——分别表示目标点的索引和移动步数。

输出格式

Output qq lines each containing a decimal number — the ii-th among them denotes the maximum probability of staying on the tit_i-th point after mim_i steps, with a proper choice of starting position PP.

Your answer will be considered correct if each number in your output differs from the corresponding one in jury's answer by at most 10−610^{-6}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is considered correct if ∣a−b∣≤10−6|a - b| \le 10^{-6}.

输出 qq 行,每行包含一个十进制数——其中第 ii 行表示:在经过 mim_i 步后,停留在第 tit_i 个点上的最大概率(可通过适当选择起始位置 PP 实现)。

若你输出的每个数字与评测组答案中对应数字的差值均不超过 10−610^{-6},则你的答案视为正确。

形式化地,设你的答案为 aa,评测组答案为 bb。当且仅当 ∣a−b∣≤10−6|a - b| \le 10^{-6} 时,你的答案被视为正确。

输入输出样例

  • 输入#1

    5
    0 0
    1 3
    2 2
    3 1
    4 4
    10
    1 1
    2 1
    3 1
    4 1
    5 1
    3 2
    3 3
    3 4
    3 5
    3 6

    输出#1

    0.50000000000000000000
    0.50000000000000000000
    0.33333333333333331483
    0.50000000000000000000
    0.50000000000000000000
    0.18518518518518517491
    0.15226337448559670862
    0.14494741655235482414
    0.14332164812274550414
    0.14296036624949901017

说明/提示

The points in SS and possible candidates for line ll are depicted in the following figure.

For the first query, when P=(−1,−3)P = (-1, -3), ll is uniquely determined to be 3x=y3x = y, and thus Kanno will move to (0,0)(0, 0) with a probability of 12\frac 1 2.

For the third query, when P=(2,2)P = (2, 2), ll is chosen equiprobably between x+y=4x + y = 4 and x=yx = y. Kanno will then move to the other four points with a probability of 12⋅13=16\frac 1 2 \cdot \frac 1 3 = \frac 1 6 each, or stay at (2,2)(2, 2) with a probability of 13\frac 1 3.

集合 SS 中的点以及直线 ll 的可能候选如以下图所示。

对于第一个查询,当 P=(−1,−3)P = (-1, -3) 时,直线 ll 唯一确定为 3x=y3x = y,因此 Kanno 将以概率 12\frac{1}{2} 移动到 (0,0)(0, 0)。

对于第三个查询,当 P=(2,2)P = (2, 2) 时,直线 ll 在 x+y=4x + y = 4 和 x=yx = y 之间等概率选取。随后,Kanno 将以概率 12⋅13=16\frac{1}{2} \cdot \frac{1}{3} = \frac{1}{6} 分别移动到其余四个点中的每一个,或以概率 13\frac{1}{3} 保持在 (2,2)(2, 2) 处不动。

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

首页