QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#15305. Doo Doo Doo

통계

Little Ika: Doo Doo Doo ~.

Hyacinthia는 전리품을 찾기 위해 "Cloud End Ruins"의 중심인 "Eye of Dawn"으로 가고 싶어 하지만, 그녀의 앞길을 막는 $n$개의 벽이 있습니다. $i$번째 벽은 원점을 중심으로 하고 반지름이 $r_i$인 원입니다. 벽에는 $k_i$개의 문이 있으며, $j$번째 문의 좌표는 $(r_i \cdot \cos(\frac{2\pi}{M} \cdot p_{i,j}), r_i \cdot \sin(\frac{2\pi}{M} \cdot p_{i,j}))$로 주어집니다. 벽의 두께와 문의 너비는 무시할 수 있으며, Hyacinthia는 벽을 넘어갈 수 없습니다.

Hyacinthia는 당신에게 $m$번 질문을 하고 싶어 합니다. 매번 그녀는 자신의 시작 위치를 알려줄 것이며, 당신은 중심까지의 최단 거리를 답해야 합니다. 시작 위치는 항상 어떤 벽의 안쪽 면이며, 벽 표면에 바로 붙어 있는 것으로 보장됩니다.

입력

첫 번째 줄에는 벽의 개수와 쿼리의 개수를 나타내는 두 정수 $n, m$ ($2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5$)이 주어집니다.

다음 $n$개의 줄은 각 벽을 설명합니다. 각 줄은 두 정수 $r_i, k_i$ ($1 \le r_i \le 10^8, 0 \le k_i \le 2 \cdot 10^5$)로 시작하며, 이는 $i$번째 벽이 반지름 $r_i$인 원이고 $k_i$개의 문이 있음을 나타냅니다. 그 뒤에는 $j$번째 문의 좌표가 $(r_i \cdot \cos(\frac{2\pi}{M} \cdot p_{i,j}), r_i \cdot \sin(\frac{2\pi}{M} \cdot p_{i,j}))$임을 나타내는 $k_i$개의 정수 $p_{i,1}, p_{i,2}, \dots, p_{i,k_i}$가 주어집니다. 여기서 $M = 3.6 \cdot 10^8$입니다. $0 \le p_{i,1} < p_{i,2} < \dots < p_{i,k_i} < M$, $k_n = 0$, $\sum_{i=1}^n k_i \le 2 \cdot 10^5$, 그리고 $1 \le r_1 < r_2 < \dots < r_n \le 10^8$임이 보장됩니다.

다음 $m$개의 줄에는 각각 두 정수 $t_i, q_i$가 주어지며, 이는 Hyacinthia가 $t_i$번째 벽의 안쪽에서 $(r_{t_i} \cdot \cos(\frac{2\pi}{M} \cdot q_i), r_{t_i} \cdot \sin(\frac{2\pi}{M} \cdot q_i))$ 지점에서 시작할 때 원점까지의 최단 거리가 얼마인지 묻는 것입니다 (도달할 수 없는 경우 "-1"을 출력하십시오).

출력

각 쿼리에 대해, 답을 나타내는 부동소수점 수를 한 줄에 출력하십시오. 도달할 수 없는 경우 "-1"을 출력하십시오. 답은 표준 정답과 비교하여 상대 오차 또는 절대 오차가 $10^{-6}$을 초과하지 않으면 정답으로 간주됩니다.

예제

입력 1

3 4
2 2 0 90000000
5 0
8 0
1 114514
2 0
2 180000000
3 233

출력 1

2.0000000000
5.0000000000
7.4056093871
-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.