#P10624. [ICPC2013 WF] Pollution Solution

[ICPC2013 WF] Pollution Solution

题目描述

As an employee of Aqueous Contaminate Management, you must monitor the pollution that gets dumped (sometimes accidentally, sometimes purposefully) into rivers, lakes and oceans. One of your jobs is to measure the impact of the pollution on various ecosystems in the water such as coral reefs, spawning grounds, and so on.

The model you use in your analysis is illustrated in Figure J.1. The shoreline (the horizontal line in the figure) lies on the xx-axis with the source of the pollution located at the origin (0,0)(0,0). The spread of the pollution into the water is represented by the semicircle, and the polygon represents the ecosystem of concern. You must determine the area of the ecosystem that is contaminated, represented by the dark blue region in the figure.

输入格式

The input consists of a single test case. A test case starts with a line containing two integers n and rr, where 3n1003 \leq n \leq 100 is the number of vertices in the polygon and 1r10001 \leq r \leq 1 000 is the radius of the pollution field. This is followed by nn lines, each containing two integers xi,yix_i, y_i, giving the coordinates of the polygon vertices in counter-clockwise order, where 1500xi1500-1 500 \leq x_i \leq 1 500 and 0yi15000 \leq y_i \leq 1 500. The polygon does not self-intersect or touch itself. No vertex lies on the circle boundary.

输出格式

Display the area of the polygon that falls within the semicircle centered at the origin with radius rr. Give the result with an absolute error of at most 10310^{-3}.

题目大意

【题目描述】

作为水污染管理公司的员工,你必须监测被排放到河流、湖泊和海洋中的污染物(有时是意外的,有时是故意的)。你的工作之一是测量污染对水中各种生态系统的影响,如珊瑚礁、产卵场所等。

Illustration

你在分析中使用的模型如图 J.1 所示。岸线(图中的水平线)位于 xx 轴上,污染源位于原点 (0,0)(0,0) 处。污染物在水中的扩散由半圆表示,多边形表示了关注的生态系统。你需要确定被污染的生态系统区域的面积,即图中的深蓝色区域。

【输入格式】

输入包含一个测试用例。测试用例以一行两个整数 nnrr 开始,其中 3n1003 \leq n \leq 100 是多边形顶点的数量,1r1,0001 \leq r \leq 1,000 是污染场的半径。接下来的 nn 行,每行包含两个整数 xi,yix_i, y_i,表示多边形顶点的坐标,顺时针给出,其中 1,500xi1,500-1,500 \leq x_i \leq 1,5000yi1,5000 \leq y_i \leq 1,500。多边形不自相交或自交。没有顶点位于半圆边界上。

【输出格式】

显示位于以原点为中心、半径为 rr 的半圆内的多边形的面积。结果的绝对误差不超过 10310^{-3}

翻译来自于:ChatGPT

6 10
-8 2
8 2
8 14
0 14
0 6
-8 14
101.576437872