QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#3288. 四面体上的会合

統計

有一天,你发现两条蠕虫 $P$ 和 $Q$ 在一个正四面体的表面上爬行,该四面体有四个顶点 $A, B, C$ 和 $D$。两条蠕虫都从顶点 $A$ 出发,径直向前爬行,并在一段时间后停止。

当蠕虫到达四面体的一条边时,它会移动到相邻的面,并保持与所跨越边的角度不变继续前进(图 G.1)。

编写一个程序,判断两条蠕虫 $P$ 和 $Q$ 在停止爬行时是否位于四面体的同一个面上。

你可以假设每条蠕虫都是一个没有长度、面积或体积的点。

图 G.1. 跨越一条边

顺便提一下,蠕虫在四面体上留下的两条轨迹的长度都是单位长度的整数倍。此处,单位长度即为四面体的边长。每条轨迹距离任何顶点(起点及其邻域除外)的距离都超过 $0.001$ 个单位长度。这意味着蠕虫至少跨越了一条边。两条蠕虫停止的位置距离任何边的距离都超过 $0.001$ 个单位长度。

蠕虫的初始爬行方向由两项指定:蠕虫出发后遇到的第一条边 $XY$,以及边 $AX$ 与蠕虫初始方向之间的夹角 $d$(单位为度)。

图 G.2. 对应样例输入 1 的蠕虫轨迹

图 G.2 展示了样例输入 1 的情况。在这种情况下,$P$ 越过了边 $CD$ 并停在与顶点 $A$ 相对的面(即底面)上,而 $Q$ 越过了边 $DB$ 并同样停在同一个面上。

输入格式

输入包含一组测试用例,格式如下:

$X_P Y_P \ d_P \ l_P$ $X_Q Y_Q \ d_Q \ l_Q$

$X_W Y_W$ ($W = P, Q$) 是蠕虫 $W$ 出发后跨越的第一条边。$X_W Y_W$ 为 $BC, CD$ 或 $DB$ 中的一个。

整数 $d_W$ ($1 \le d_W \le 59$) 是边 $AX_W$ 与蠕虫 $W$ 在面 $\triangle AX_W Y_W$ 上的初始方向之间的夹角(单位为度)。

整数 $l_W$ ($1 \le l_W \le 20$) 是蠕虫 $W$ 在表面上留下的轨迹长度(以单位长度计)。

输出格式

当且仅当两条蠕虫停在四面体的同一个面上时,输出 YES。否则,输出 NO

样例

样例输入 1

CD 30 1
DB 30 1

样例输出 1

YES

样例输入 2

BC 1 1
DB 59 1

样例输出 2

YES

样例输入 3

BC 29 20
BC 32 20

样例输出 3

NO

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.