QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 2048 MB 總分: 100

#3870. 环形迷宫

统计

给定一个圆形迷宫,如图所示。

请判断该迷宫是否有解,即是否存在一条从中心到迷宫外部且不接触任何墙壁的路径。迷宫由 $n$ 面墙描述。每面墙可以是圆弧形或直线形。

  • 圆弧形墙由半径 $r$(距中心的距离)以及两个角度 $\theta_1, \theta_2$ 描述,这两个角度表示墙在顺时针方向上的起点和终点。注意,交换这两个角度会改变墙的位置。
  • 直线形墙由角度 $\theta$(墙的方向)以及两个半径 $r_1 < r_2$ 描述,这两个半径表示墙的起点和终点。

角度以度为单位测量;角度 $0$ 对应于正上方;角度顺时针增加(因此正东方对应角度 $90$)。

输入格式

每个测试包含多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 20$),表示测试用例的数量。接下来是 $t$ 个测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($1 \le n \le 5000$),表示墙的数量。

接下来的 $n$ 行,每行包含一个字符(C 表示圆弧形,S 表示直线形)和三个整数:

  • 如果是圆弧形墙,则为 $r, \theta_1, \theta_2$ ($1 \le r \le 20$ 且 $0 \le \theta_1, \theta_2 < 360$,且 $\theta_1 \neq \theta_2$);
  • 如果是直线形墙,则为 $r_1, r_2, \theta$ ($1 \le r_1 < r_2 \le 20$ 且 $0 \le \theta < 360$)。

保证圆弧形墙之间不会重叠(但两个圆弧形墙可能在一个或两个点相交),直线形墙之间不会重叠(但两个直线形墙可能在一个点相交)。然而,圆弧形墙和直线形墙可以任意相交。

输出格式

对于每个测试用例,如果迷宫有解,输出 YES,否则输出 NO

样例

样例输入 1

2
5
C 1 180 90
C 5 250 230
C 10 150 140
C 20 185 180
S 1 20 180
6
C 1 180 90
C 5 250 230
C 10 150 140
C 20 185 180
S 1 20 180
S 5 10 0

样例输出 1

YES
NO

说明

样例 1 中的两个测试用例分别对应图片中的两个迷宫。

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.