QOJ.ac

QOJ

Límite de tiempo: 9 s Límite de memoria: 1024 MB Puntuación total: 100

#1818. 蘋果園

Estadísticas

Farmer John 的農場裡有許多蘋果樹。每棵蘋果樹都有一個圓形的區域,在炎熱的夏天提供遮蔭。Farmer John 正在為他的乳牛建造圍欄,並考慮了幾個地點。對於每個圍起來的區域,他想知道該區域中有多少比例是處於遮蔭下的。

每個擬定的圍欄區域形狀皆為矩形,且邊與座標軸平行,由其左下角座標以及區域的寬度和高度來指定。請計算每個擬定的圍欄矩形中,遮蔭區域所佔的百分比。

輸入格式

輸入的第一行包含兩個整數 $n$ ($1 \le n \le 3\,000$) 和 $q$ ($1 \le q \le 3\,000$),其中 $n$ 是 Farmer John 果園中的蘋果樹數量,$q$ 是他想要測試的矩形圍欄區域數量。

接下來的 $n$ 行,每行包含三個整數 $x, y$ ($-10^6 \le x, y \le 10^6$) 和 $r$ ($1 \le r \le 10^6$)。每行描述一棵樹的圓形遮蔭區域,其中 $(x, y)$ 為其圓心,$r$ 為其半徑。請注意,樹木的樹幹可能非常扭曲,因此兩塊遮蔭區域可能具有相同的圓心,甚至完全重疊。

接下來的 $q$ 行,每行包含四個整數 $x, y$ ($-10^6 \le x, y \le 10^6$),$w$ 和 $h$ ($1 \le w, h \le 10^6$)。每行描述一個 Farmer John 想要測試的矩形區域。該矩形的對角線端點為 $(x, y)$ 到 $(x + w, y + h)$。

輸出格式

輸出 $q$ 行,每行包含一個實數,代表該矩形中被遮蔭的百分比(範圍為 0 到 100)。請依照輸入中矩形出現的順序輸出百分比。每個數值與評測系統答案的相對誤差或絕對誤差應在 $10^{-5}$ 以內。

範例

範例輸入 1

2 2
0 0 3
2 1 4
0 0 3 3
-3 -3 6 6

範例輸出 1

100.000000000
89.536784729

範例輸入 2

4 3
-1 -1 3
1 -1 3
-1 1 3
1 1 3
-4 -4 8 8
-1 -4 2 8
-3 -1 12 3

範例輸出 2

87.222142378
98.586991373
57.862330458

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.