#P1183. 多边形的面积
多边形的面积
Description
Given a simple polygon without holes whose edges are vertical or horizontal, compute the area of the polygon.
The polygon is placed on an Cartesian plane, and all its edges are parallel to one of the two coordinate axes. The vertex coordinates are given in counterclockwise order. All coordinates are integers, so the area of the polygon is also an integer.
Note: There may be three consecutive vertices that are collinear.
Input Format
The first line contains the number of vertices .
The next lines each contain the coordinates and of a vertex, separated by a space.
The vertices are given one by one in counterclockwise order. The polygon is closed by drawing an edge from the last vertex to the first.
Output Format
One line with a single integer, representing the area of the polygon.
10
0 0
4 0
4 1
3 1
3 3
2 3
2 2
1 2
1 3
0 3
9
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号