Problems > Area of a Polygon > Editorial

Area of a Polygon — Solution & Editorial

Back to the Problem

Shoelace formula: twice the area is |∑ (xiyi+1 − xi+1yi)| — keep it in integers and format the half at output.

Complexity: O(N)

Watch out: Floating-point shoelace drifts; twice-the-area stays exactly integral.