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$ 番目の壁は原点 $(0, 0)$ を中心とする半径 $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$ 回の質問をします。毎回、彼女の出発点が与えられるので、中心までの最短距離を答えてください。出発点は必ずいずれかの壁の内側かつ壁の表面に接していることが保証されています。

入力

最初の行には、壁の数とクエリの数を表す2つの整数 $n, m$ ($2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5$) が含まれます。

続く $n$ 行は各壁について記述します。各行は2つの整数 $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(\frac{2\pi}{M} \cdot p_{i,j}), r_i \cdot \sin(\frac{2\pi}{M} \cdot p_{i,j}))$ であることを表します。ここで $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$ 行には、それぞれ2つの整数 $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行で出力してください。到達不可能な場合は "-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.