CSES - Aalto Competitive Programming 2024 - wk10 - Mon - Results
Submission details
Task:Polygon area
Sender:joaquimballester
Submission time:2024-11-11 16:26:13 +0200
Language:C++ (C++11)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    for(ll i = 0; i < n; ++i){
        ll a,b;
        cin >> a >> b;
        v[i] = make_pair(a,b);
    }
    ll area = 0;

    for (ll i = 0; i < n; i++) {
        area += (v[i].first
                    * v[(i + 1) % n].second
                - v[(i + 1) % n].first * v[i].second);
    }
    if(area < 0) area = (-1)*area;
    cout << area<<endl;

}

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