QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372266 | #1950. Surveillance | ohiostatescarlet# | TL | 9ms | 9548kb | Python3 | 1.6kb | 2024-03-31 08:43:05 | 2024-03-31 08:43:05 |
Judging History
answer
import math
n = int(input())
points = [list(map(int, input().split())) for _ in range(n)]
xs = [p[0] for p in points]
ys = [p[1] for p in points]
xmax = max(xs)
ymax = max(ys)
xmin = min(xs)
ymin = min(ys)
atotal = xmax - xmin
btotal = ymax - ymin
found = False
for i in range(len(points)):
if points[i][0] not in [xmin, xmax] and points[i][1] not in [ymin, ymax]:
a2 = max(abs(points[i][0] - points[(i + 1) % n][0]), abs(points[i][0] - points[(i - 1) % n][0]))
b2 = max(abs(points[i][1] - points[(i + 1) % n][1]), abs(points[i][1] - points[(i - 1) % n][1]))
found = True
break
def solve(a1, a2, b1, b2):
rang = [[0, 0]]
inc = a1 / 1000000
x = inc
while True:
theta1 = math.atan(b2 / x)
theta2 = math.atan(b2 / (2*a1 - x))
theta3 = math.pi - theta1 - theta2
d1 = b1 / math.tan(theta1)
d2 = 2 * d1 * math.sin(theta1) / math.sin(theta3)
dx = d2 * math.cos(theta2)
dy = d2 * math.sin(theta2)
# print(x, d2, dx, dy)
if dx > a2 or dy > b1:
break
rang.append([dx, dy])
x += inc
rang.append([a2, b1])
total = 0
for i in range(len(rang)-1):
total += (rang[i+1][0] - rang[i][0]) * (rang[i+1][1] + rang[i][1]) / 2
return total
if not found:
print(atotal * btotal)
else:
a1 = atotal - a2
b1 = btotal - b2
# print(atotal, a1, a2)
# print(btotal, b1, b2)
total = 0
total += solve(a1, a2, b1, b2)
total += solve(b1, b2, a1, a2)
print(atotal * btotal - a2 * b2 - total)
详细
Test #1:
score: 100
Accepted
time: 9ms
memory: 9548kb
input:
4 -5 6 -5 -2 10 -2 10 6
output:
120
result:
ok found '120.0000000', expected '120.0000000', error '0.0000000'
Test #2:
score: -100
Time Limit Exceeded
input:
6 627 -788 444 -788 444 -986 -102 -986 -102 -993 627 -993