| Task: | Polygon area |
| Sender: | aalto26jm_017 |
| Submission time: | 2026-11-09 16:37:13 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | WRONG ANSWER | 0.01 s | details |
| #3 | WRONG ANSWER | 0.00 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
typedef Point P;
T x, y;
explicit Point(T x=0, T y=0) : x(x), y(y) { }
bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
P operator+(P p) const { return P(x+p.x, y+p.y); }
P operator-(P p) const { return P(x-p.x, y-p.y); }
P operator*(T d) const { return P(x*d, y*d); }
P operator/(T d) const { return P(x/d, y/d); }
T dot(P p) const { return x*p.x + y*p.y; }
T cross(P p) const { return x*p.y - y*p.x; }
T cross(P a, P b) const { return (a-*this).cross(b-*this); }
T dist2() const { return x*x + y*y; }
double dist() const { return sqrt((double)dist2()); }
// angle to x =axis in i n t e r v a l [=pi , pi ]
double angle() const { return atan2(y, x); }
P unit() const { return *this/dist(); } // makes d i s t ()=1
P perp() const { return P(-y, x); } // rotates +90 degrees
P normal() const { return perp().unit(); }
// returns point rotated ’a ’ radians ccw around the origin
P rotate(double a) const {
return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
friend ostream& operator<<(ostream& os, P p) {
return os << "(" << p.x << "," << p.y << ")"; }
} ;
template<class T>
T polygonArea2(vector<Point<T>>& v) {
T a = v.back().cross(v[0]);
rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
return a;
}
int main() {
int n;
cin >> n;
vector<Point<int>> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].x >> p[i].y;
}
cout << polygonArea2<int>(p) << 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: WRONG ANSWER
| input |
|---|
| 1000 365625896 -113418831 278762563 38777445 250367343 -96991975 175866909 -129766978 ... |
| correct output |
|---|
| 4053466653883387139 |
| user output |
|---|
| 228347139 |
Feedback: Incorrect character on line 1 col 1: expected "405346665388...", got "228347139"
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 4 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 -1000000000 |
| correct output |
|---|
| 8000000000000000000 |
| user output |
|---|
| -991952896 |
Feedback: Incorrect character on line 1 col 1: expected "800000000000...", got "-991952896"
