Cod sursa(job #3376495)

Utilizator Alias47John Doe Alias47 Data 18 noiembrie 2026 07:42:24
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vc;
typedef vector<vector<int>> matrix;
#define ft(n) for(ull i=1; i<=n; i++)
#define sp ' '
string file = "aria";
ifstream f(file + ".in");
ofstream g(file + ".out");

struct pct
{
    long double x, y;
};
vector<pct> v;
int n;

int ccw(pct p1, pct p2, pct p)
{
    return (p2.x - p1.x) * (p.y - p1.y) - (p2.y - p1.y) * (p.x - p1.x);
}
long double area(vector<pct>& v)
{
    int res=0;
    v[n + 1] = v[1];
    for (int i = 2; i <= n + 1; i++)
    {
        res += ccw(v[0], v[i-1], v[i]); //triangle with tip in (0,0)
    }
    return res / 2.0;
}

int main()
{
    f >> n;
    v.resize(n + 2, {0,0});
    for (int i = 1; i <= n; i++)
    {
        f >> v[i].x >> v[i].y;
    }
    g << fixed << setprecision(6) << area(v);
    return 0;
}