| Task: | Polygon area |
| Sender: | erimey |
| Submission time: | 2025-11-10 16:37:50 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.06 s | details |
| #3 | ACCEPTED | 0.04 s | details |
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 |
