| Task: | Polygon area |
| Sender: | tjaa |
| Submission time: | 2025-11-10 16:49:12 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.00 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long C;
typedef complex<C> P;
#define X real()
#define Y imag()
C cross(const P& a, const P& b) {
return (conj(a)*b).Y;
}
int main () {
// freopen("input.txt", "r", stdin);
int n;
cin >> n;
long long A = 0;
int x0, y0;
cin >> x0 >> y0;
P prev = {x0, y0};
while(--n) {
int x, y;
cin >> x >> y;
P cur = {x, y};
A += cross(prev, cur);
prev = cur;
}
A += cross(prev, {x0, y0});
cout << abs(A) << '\n';
return 0;
}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 |
