QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 1024 MB Puntuación total: 100

#3978. 发射相位炮

Estadísticas

作为飞船的船长,你从未遇到过比现在潜入的这艘敌舰更凶猛的敌人。你立即启动了大型相位炮,希望在敌舰发现你之前将其摧毁。你不能有任何失误,如果想在与敌方旗舰的对抗中有一线生机,这一击必须完美无缺。

你开始为相位光束充能,并从档案中调取了敌舰的房间布局。你正位于敌舰的正上方,从这里可以将敌舰的布局建模为一张二维的房间地图。在这张地图中,每个房间都是一个边平行于 $x$ 轴和 $y$ 轴的矩形(轴对齐矩形),且任意两个房间互不相交(甚至连一个点都不重合)。

相位光束通过一个点 $(x, y)$ 和一个角度 $\vartheta$ 来配置。相位光束将从 $(x, y)$ 出发,沿 $\vartheta$ 指定的方向传播距离 $\ell$,对光束触及的每一个房间造成严重破坏。因此,你的目标是尽可能多地击中房间。

相位光束即将充能完毕,现在唯一缺少的就是武器的最佳配置。不幸的是,这比你预想的要困难。然而,距离充能完成还有十秒钟,因此你决定编写一个计算机程序来解决这个问题。

输入格式

输入的第一行包含两个整数 $r$ 和 $\ell$ ($1 \le r \le 15, 1 \le \ell \le 1000$),其中 $r$ 是旗舰中房间的数量,$\ell$ 是相位炮射击的长度。

接下来 $r$ 行,每行包含四个整数 $x_1, y_1, x_2, y_2$ ($0 \le x_1 < x_2 \le 1000, 0 \le y_1 < y_2 \le 1000$),表示旗舰中有一个左下角为 $(x_1, y_1)$、右上角为 $(x_2, y_2)$ 的房间。

输出格式

输出一行,表示单次相位光束射击最多能击中的房间数量。请注意,如果光束触及一个房间,则计为击中。

你可以假设答案在以下意义上是数值稳定的:如果所有房间在四个方向上都向外扩展 $10^{-6}$ 的距离,答案保持不变。

样例输入 1 的解法示意图

样例

样例输入 1

5 8
2 1 4 5
5 1 12 4
5 5 9 10
1 6 4 10
2 11 7 14

样例输出 1

4

样例输入 2

3 6
2 2 3 3
5 3 6 4
6 6 7 7

样例输出 2

3

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.