Task: | Polygon area |
Sender: | HFalke |
Submission time: | 2024-11-11 16:21:13 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
Code
#include <bits/stdc++.h> using namespace std; //Definitions for quicker writing #define REP(i,a,b) for (int i = a; i < b; i++) #define clz __builtin_clz #define ctz __builtin_ctz #define popct __builtin_popcount #define PB push_back #define MP make_pair #define F first #define S second #define X real() #define Y imag() //Typedefs for quicker writing typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef pair<int,int> pi; typedef pair<long long, long long> pl; typedef complex<long long> po; //Max values const long long lmx = LLONG_MAX; const int imx = INT_MAX; vector<po> points(1001); ll cross(po v, po w){ return v.X * w.Y - v.Y * w.X; } ll shoelace(ll n){ ll sum = 0; REP(i,0,n-1){ sum += cross(points[i],points[i+1]); } sum += cross(points[n-1],points[0]); return abs(sum); } int main() { //IO optimization ios::sync_with_stdio(0); cin.tie(0); //Input definition ll n; //Read In cin >> n; ll a,b; REP(i,0,n){ cin >> a >> b; points[i] = {a,b}; } //Write out cout << shoelace(n) << "\n"; //Return 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 |