QOJ.ac

QOJ

Time Limit: 9 s Memory Limit: 1024 MB Total points: 100

#1818. リンゴ園

Statistics

Farmer Johnの農場には多くのリンゴの木があります。各リンゴの木は、暑い夏の間、日陰を提供する円形の領域を持っています。Farmer Johnは牛のための囲いを作ろうとしており、いくつかの場所を候補として考えています。それぞれの囲いについて、その提案された領域のうちどれだけの割合が日陰になっているかを知りたいと考えています。

提案される各囲い領域は長方形の形状をしており、軸に平行で、左下の角の座標と、その領域の幅および高さによって指定されます。提案された各長方形の囲いについて、日陰になっている領域の割合を計算してください。

入力

入力の最初の行には、2つの整数 $n$ ($1 \le n \le 3\,000$) と $q$ ($1 \le q \le 3\,000$) が含まれます。ここで、$n$ はFarmer Johnの果樹園にあるリンゴの木の数、$q$ は彼がテストしたい長方形の囲いの数です。

続く $n$ 行のそれぞれには、3つの整数 $x, y$ ($-10^6 \le x, y \le 10^6$) と $r$ ($1 \le r \le 10^6$) が含まれます。各行は木の円形の日陰領域を表しており、$(x, y)$ はその中心、 $r$ はその半径です。木は非常に曲がりくねった幹を持っている可能性があるため、2つの日陰領域が同じ中心を持っていたり、完全に同一であったりする可能性があることに注意してください。

続く $q$ 行のそれぞれには、4つの整数 $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のスケールで表した実数を1つ含めます。入力に現れる順序で長方形の割合を出力してください。各値は、判定者の答えに対して相対誤差または絶対誤差が $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.