QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372268#1950. Surveillanceohiostatescarlet#WA 460ms54564kbPython31.6kb2024-03-31 08:47:192024-03-31 08:47:20

Judging History

你现在查看的是最新测评结果

  • [2024-03-31 08:47:20]
  • 评测
  • 测评结果:WA
  • 用时:460ms
  • 内存:54564kb
  • [2024-03-31 08:47:19]
  • 提交

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 / 300000

    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(f"{atotal * btotal:.10f}")
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(f"{atotal * btotal - a2 * b2 - total:.10f}")



详细

Test #1:

score: 100
Accepted
time: 9ms
memory: 9656kb

input:

4
-5 6
-5 -2
10 -2
10 6

output:

120.0000000000

result:

ok found '120.0000000', expected '120.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 460ms
memory: 54564kb

input:

6
627 -788
444 -788
444 -986
-102 -986
-102 -993
627 -993

output:

1597.4226884991

result:

ok found '1597.4226885', expected '1597.4226884', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 9ms
memory: 10028kb

input:

6
340 110
340 375
-1000 375
-1000 -135
353 -135
353 110

output:

685624.4401468263

result:

wrong answer 1st numbers differ - expected: '685643.4381452', found: '685624.4401468', error = '0.0000277'