Task: | Polygon area |
Sender: | htoik |
Submission time: | 2024-11-11 16:25:53 +0200 |
Language: | C++ (C++20) |
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 |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 24 | for(int i=0; i<n-1; i++){ | ~^~~~
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int main(){ ios::sync_with_stdio(0); cin.tie(0); ull n; cin >> n; ll sum = 0; vector<pair<ll,ll>> ps; ps.reserve(n); for(ull i=0; i<n; i++){ ll x, y; cin >> x >> y; ps.push_back({x,y}); } for(int i=0; i<n-1; i++){ sum += ps[i].first * ps[i+1].second - ps[i+1].first * ps[i].second; } sum += ps[n-1].first * ps[0].second - ps[0].first * ps[n-1].second; cout << (abs(sum)) << "\n"; }
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 |