QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 512 MB 총점: 100 해킹 가능 ✓

#14539. 异或环

통계

CCPC(中国大学生程序设计竞赛)将在 A 市举行。A 市可以看作一个无限的二维平面。将有 $n$ 名选手参加比赛。这 $n$ 个人从 $1$ 到 $n$ 编号,每个人在 A 市都有一个初始位置和一个数值 $a_i$。

组织者需要为比赛选择一个场地。对于每个人 $i$,当且仅当比赛场地到其初始位置的距离不大于 $d$ 时,他/她才会感到开心。注意,场地的坐标可以是任意实数。

为了确定比赛场地是否合适,组织者定义 $f(P)$ 为:如果将点 $P$ 选为比赛场地,部分开心的选手的数值的最大异或和。

设 $S(P)$ 表示所有与点 $P$ 的距离不大于 $d$ 的选手的集合,$g(T)$ 表示集合 $T$ 中所有选手的 $a_i$ 的异或和(特别地,$g(\emptyset) = 0$),$f(P) = \max_{T \subseteq S(P)} g(T)$。当且仅当 $f(P) \ge k$ 时,点 $P$ 被认为是一个好的场地。

你需要求出最小的非负实数 $d$,使得至少存在一个好的场地。

注意,点 $A(x_A, y_A)$ 与 $B(x_B, y_B)$ 之间的距离为 $\sqrt{(x_A - x_B)^2 + (y_A - y_B)^2}$。

输入格式

第一行包含两个整数 $n$($1 \le n \le 1000$)和 $k$($0 \le k < 2^{20}$),分别表示参赛人数和好场地的最小价值。

接下来的 $n$ 行,每行包含三个整数 $x_i, y_i, a_i$($|x_i|, |y_i| \le 10^4$,$0 \le a_i < 2^{20}$),分别表示第 $i$ 个人的初始位置和数值。

输出格式

输出一个非负实数 $d$,表示使得至少存在一个场地的价值不小于 $k$ 的最小距离。

当且仅当你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$ 时,答案被视为正确。

如果不存在这样的 $d$,请输出 -1

样例

输入样例 1

4 39
-1 -1 5
2 3 37
-1 2 2
-1 -1 14

输出样例 1

1.5811388301

输入样例 2

4 16
1 1 4
5 1 4
1 9 1
9 8 10

输出样例 2

-1

输入样例 3

2 0
11 45 14
191 98 10

输出样例 3

0.0000000000

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.