CF1628F.Spaceship Crisis Management

NOI/NOI+/CTSC

通过率:0%

时间限制:8.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

NASA (Norwegian Astronaut Stuff Association) is developing a new steering system for spaceships. But in its current state, it wouldn't be very safe if the spaceship would end up in a bunch of space junk. To make the steering system safe, they need to answer the following:

Given the target position t=(0,0)t = (0, 0), a set of nn pieces of space junk ll described by line segments li=((aix,aiy),(bix,biy))l_i = ((a_{ix}, a_{iy}), (b_{ix}, b_{iy})), and a starting position s=(sx,sy)s = (s_x, s_y), is there a direction such that floating in that direction from the starting position would lead to the target position?

When the spaceship hits a piece of space junk, what happens depends on the absolute difference in angle between the floating direction and the line segment, θ\theta:

  • If θ<45∘\theta \lt 45^{\circ}, the spaceship slides along the piece of space junk in the direction that minimizes the change in angle, and when the spaceship slides off the end of the space junk, it continues floating in the direction it came in (before hitting the space junk).
  • If θ≥45∘\theta \ge 45^{\circ}, the spaceship stops, because there is too much friction to slide along the space junk.

You are only given the set of pieces of space junk once, and the target position is always (0,0)(0, 0), but there are qq queries, each with a starting position sj=(sjx,sjy)s_j = (s_{jx}, s_{jy}).

Answer the above question for each query.

美国国家航空航天局(挪威宇航员装备协会,NASA)正在为宇宙飞船开发一种新型转向系统。但目前该系统尚不安全:若飞船意外进入一片太空垃圾区域,则可能引发危险。为确保转向系统安全,需解决如下问题:

给定目标位置 t=(0,0)t = (0, 0)、由 nn 段线段构成的太空垃圾集合 ll,其中第 ii 段线段为 li=((aix,aiy),(bix,biy))l_i = ((a_{ix}, a_{iy}), (b_{ix}, b_{iy})),以及起始位置 s=(sx,sy)s = (s_x, s_y),是否存在某个方向,使得飞船从起始位置沿该方向自由漂浮,最终可抵达目标位置?

当飞船撞击某块太空垃圾时,其后续行为取决于漂浮方向与该线段之间的夹角绝对值 θ\theta:

  • 若 θ<45∘\theta \lt 45^{\circ},飞船将沿该太空垃圾线段滑动,滑动方向为使角度变化最小的方向;当飞船滑出线段端点后,继续以撞击前的原始方向漂浮;
  • 若 θ≥45∘\theta \ge 45^{\circ},飞船将停止运动,因为此时摩擦力过大,无法沿太空垃圾滑动。

你仅被给定一次太空垃圾集合,且目标位置恒为 (0,0)(0, 0);但共有 qq 个查询,每个查询给出一个起始位置 sj=(sjx,sjy)s_j = (s_{jx}, s_{jy})。

请对每个查询回答上述问题。

输入格式

The first line contains the the integer nn (1≤n≤15001 \le n \le 1500).

Then follows nn lines, the ii-th of which containing the 44 integers aixa_{ix}, aiya_{iy}, bixb_{ix}, and biyb_{iy} (∣aix∣,∣aiy∣,∣bix∣,∣biy∣≤1000|a_{ix}|, |a_{iy}|, |b_{ix}|, |b_{iy}| \le 1000).

Then follows a line containing the integer qq (1≤q≤10001 \le q \le 1000).

Then follows qq lines, the jj-th of which containing the 22 integers sjxs_{jx} and sjys_{jy} (∣sjx∣,∣sjy∣≤1000|s_{jx}|, |s_{jy}| \le 1000).

It is guaranteed that none of the segments in ll cross or touch, that tt is not on any segment in ll, that sjs_j is not on any segment in ll, and that s≠ts \neq t.

第一行包含一个整数 nn(1≤n≤15001 \le n \le 1500)。

接下来是 nn 行,其中第 ii 行包含四个整数 aixa_{ix}、aiya_{iy}、bixb_{ix} 和 biyb_{iy}(满足 ∣aix∣,∣aiy∣,∣bix∣,∣biy∣≤1000|a_{ix}|, |a_{iy}|, |b_{ix}|, |b_{iy}| \le 1000)。

随后是一行,包含一个整数 qq(1≤q≤10001 \le q \le 1000)。

接下来是 qq 行,其中第 jj 行包含两个整数 sjxs_{jx} 和 sjys_{jy}(满足 ∣sjx∣,∣sjy∣≤1000|s_{jx}|, |s_{jy}| \le 1000)。

保证:线段集合 ll 中任意两条线段均不相交也不接触;点 tt 不在 ll 的任意一条线段上;点 sjs_j 不在 ll 的任意一条线段上;且 s≠ts \neq t。

输出格式

For each query sjs_j print an answer. If there exists a direction such that floating from sjs_j in that direction, possibly sliding along some pieces of space junk, leads to tt, print "YES". Otherwise, print "NO" (case insensitive).

对于每个查询 sjs_j,输出一个答案。如果存在某个方向,使得从 sjs_j 沿该方向漂浮(过程中可能沿某些太空垃圾滑动)能够到达 tt,则输出 "YES";否则输出 "NO"(不区分大小写)。

输入输出样例

  • 输入#1

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

    输出#1

    YES
    YES
    YES
    YES
    YES
    NO
    NO
    NO
    YES
    YES
    NO
    NO
    NO
    YES

说明/提示

The blue cross represents the target location, and the other blue line segments represent the space junk.

Green dots represent starting locations where the answer is yes, and red dots represent starting locations where the answer is no.

The yellow lines are possible paths to the target location for the 33rd and 1414th queries.

The black line is a possible path from the starting location in the 66th query, but it barely misses the target location.

蓝色十字表示目标位置,其余蓝色线段表示太空垃圾。

绿色圆点表示答案为“是”的起始位置,红色圆点表示答案为“否”的起始位置。

黄色线条表示第 3 次和第 14 次查询中通往目标位置的可能路径。

黑色线条表示第 6 次查询中从起始位置出发的一条可能路径,但它恰好未到达目标位置。

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

首页