| Task: | Polygon area |
| Sender: | aalto26jm_008 |
| Submission time: | 2026-11-09 16:29:49 +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 <iostream>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n_points;
cin >> n_points;
long long x1, y1;
long long x2, y2;
cin >> x1 >> y1;
long long sum = 0;
long long fx, fy;
fx = x1;
fy = y1;
for(int i = 1; i < n_points; ++i)
{
x2 = x1;
y2 = y1;
cin >> x1 >> y1;
sum += x2 * y1 - x1 * y2;
}
sum += x1 * fy - fx * y1;
sum = abs(sum);
cout << sum << endl;
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 |
