QOJ.ac

QOJ

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

#15305. Doo Doo Doo

통계

Little Ika: Doo Doo Doo ∼.

Hyacinthia 想要前往「雲端遺跡」黎明之眼(Eye of Dawn)的中心尋找寶藏,但有 $n$ 道牆擋住了她的去路。第 $i$ 道牆是以原點 $(0, 0)$ 為圓心、半徑為 $r_i$ 的圓。牆上有 $k_i$ 個門,第 $j$ 個門的座標由 $r_i \cdot \cos \left( \frac{2\pi}{M} \cdot p_{i,j} \right), r_i \cdot \sin \left( \frac{2\pi}{M} \cdot p_{i,j} \right)$ 給出。牆的厚度和門的寬度皆可忽略不計,且 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$ 個門。隨後是 $k_i$ 個整數 $p_{i,1}, p_{i,2}, \dots, p_{i,k_i}$,代表第 $j$ 個門的座標為 $r_i \cdot \cos \left( \frac{2\pi}{M} \cdot p_{i,j} \right), r_i \cdot \sin \left( \frac{2\pi}{M} \cdot p_{i,j} \right)$,其中 $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 \left( \frac{2\pi}{M} \cdot q_i \right), r_{t_i} \cdot \sin \left( \frac{2\pi}{M} \cdot q_i \right)$ 出發,到原點的最短距離是多少(若無法到達,請輸出 "-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.