QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#12350. 噩梦

统计

一辆汽车正行驶在 N 国著名的破旧道路上,准备从 A 点前往 B 点。已知连接这两地的唯一道路上有 $n$ 个坑洞,而汽车最多只能承受 $k$ 个坑洞。如果再多遇到一个坑洞,汽车就会彻底抛锚并散架。

一个坑洞可以表示为一个三维多面体,其一个面位于水平的 $Oxy$ 平面上,其余部分位于该平面下方。顶面即为坑洞的“洞口”。如果作一个垂直平面,使得顶面的任意一条边都在该垂直平面内,则整个多面体将位于该平面的某一侧半空间中。从上方俯视(移除顶面后),该多面体表面的每一点都是可见的。

汽车可以看作 $Oxy$ 平面上的一个矩形,其四个角即为车轮。汽车从平坦的表面(无坑洞)开始行驶,始终沿一个预定义的固定方向移动。如果汽车的任意一个车轮进入了坑洞(进入的深度非零),则视为撞上了坑洞。对于每个坑洞,仅考虑第一次撞击。仅撞击坑洞边缘不计入撞击。为简化起见,假设汽车始终在 $Oxy$ 平面上移动,即使在撞击坑洞时也是如此。

请问汽车在抛锚前能行驶多远?

输入格式

第一行包含一个整数 $k$:汽车能承受的坑洞数量($1 \le k \le 50$)。

接下来的四行描述了汽车车轮在 $Oxy$ 平面上的坐标。每行描述格式为 “$x$ $y$”,其中 $x$ 和 $y$ 为整数,绝对值不超过 $10\,000$。描述顺序如下:

  1. 前右轮;
  2. 前左轮;
  3. 后左轮;
  4. 后右轮。

汽车沿着垂直于连接两个前轮的直线的方向行驶(类似于普通汽车)。

下一行包含一个整数 $n$:坑洞的数量($1 \le n \le 50$)。随后是各个坑洞的描述。

每个坑洞的描述方式如下:首先是一行,包含一个整数 $m_i$:第 $i$ 个坑洞模型多面体的顶点数($4 \le m_i \le 300$)。接下来的 $m_i$ 行,每行描述一个顶点,包含三个整数 $x, y, z$:顶点的坐标($-10^4 \le x, y \le 10^4, -10^4 \le z \le 0$)。

保证坑洞之间互不相交且互不接触。

输出格式

输出汽车在抛锚前能行驶的距离。如果绝对误差不超过 $10^{-4}$,则答案被接受。如果汽车永远不会抛锚,输出 “oo”(两个小写字母 “o”)。

样例

样例输入 1

2
0 0
-2 2
-4 0
-2 -2
3
5
1 1 0
3 3 0
2 2 -1
1 3 0
3 1 0
5
0 4 0
1 5 -1
0 6 0
2 6 0
2 4 0
5
6 6 0
6 4 0
4 4 0
5 5 -1
4 6 0

样例输出 1

5.65685425

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.