Submission details
Task:Polygon area
Sender:Dereden
Submission time:2025-11-10 16:32:58 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails

Code

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <complex>

typedef long long ll;

using namespace std;

typedef complex<ll> P;

ll cross(P a, P b) {
    return (conj(a)*b).imag();
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.txt", "r", stdin); // TODO: REMOVE THIS YOU STUPID ****

    int n;
    cin >> n;
    vector<P> points(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        points[i] = {x, y};
    }
    points.push_back(points[0]);
    ll total = 0;
    for (int i = 0; i < n; i++) {
       total += cross(points[i], points[i+1]);
    }
    total = llabs(total);
    cout << total;
}

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