Submission details
Task:Polygon area
Sender:erimey
Submission time:2025-11-10 16:37:50 +0200
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.04 sdetails

Code


def polygon(n,points):
    segements = []
    prev = points[-1]
    for i in points:
        segements.append((prev,i))
        prev = i
    return abs(sum(x0*y1 - x1*y0 for ([x0, y0], [x1, y1]) in segements))




if __name__ == "__main__":
    points = []
    n = int(input())
    for i in range(n):
        points.append([int(input) for input in input().split(" ")])
    res = polygon(n, points)
    print(res)


"""
Input:
4
1 1
4 2
3 5
1 4

Output:
16
"""

Test details

Test 1

Verdict: ACCEPTED

input
100
-7 -19
91 77
100 100
64 60
...

correct output
43582

user output
43582

Test 2

Verdict: ACCEPTED

input
1000
365625896 -113418831
278762563 38777445
250367343 -96991975
175866909 -129766978
...

correct output
4053466653883387139

user output
4053466653883387139

Test 3

Verdict: ACCEPTED

input
4
-1000000000 -1000000000
-1000000000 1000000000
1000000000 1000000000
1000000000 -1000000000

correct output
8000000000000000000

user output
8000000000000000000