#include #include #include #include #include #define SQR(x) (long(x) * long(x)) #define SQR_DIST(a, b) (SQR(a->x - b->x) + SQR(a->y - b->y)) using namespace std; struct Point { int x, y; bool visited; Point(int _x, int _y) { x = _x; y = _y; visited = false; } Point() { } void print() { cerr << "(" << x << ", " << y << ")" << endl; } }; union Coords { struct { int x, y; }; long long id; void print() { cerr << "(" << x << ", " << y << ")" << endl; } }; struct PointReferece { bool compare_from_left; Point *point; PointReferece(Point *_point, bool _compare_from_left) { point = _point; compare_from_left = _compare_from_left; } bool operator<(PointReferece other) { return compare_from_left ? point->x < other.point->x : point->y < other.point->y; } }; Coords find_fourth_of_rect(Point *A, Point *B, Point *C) { Coords rt; long long a = SQR_DIST(C, B); long long b = SQR_DIST(C, A); long long c = SQR_DIST(A, B); long long mx = max(max(a, b), c); Point *Ar, *Br, *Cr; if (mx == a) { Ar = A; Br = B; Cr = C; } else if (mx == b) { Ar = B; Br = A; Cr = C; } else if (mx == c) { Ar = C; Br = B; Cr = A; } rt.x = Br->x + Cr->x - Ar->x; rt.y = Br->y + Cr->y - Ar->y; return rt; } long long find_area_of_rect(Point *A, Point*B, Point *C) { long long a = SQR_DIST(C, B); long long b = SQR_DIST(C, A); long long c = SQR_DIST(A, B); long long mx = max(max(a, b), c); Point *Ar, *Br, *Cr; if (mx == a) { Ar = A; Br = B; Cr = C; } else if (mx == b) { Ar = B; Br = A; Cr = C; } else if (mx == c) { Ar = C; Br = B; Cr = A; } return SQR_DIST(Ar,Cr) * SQR_DIST(Ar, Br); } int main() { int N; cin >> N; vector points; vector points_from_left; vector points_from_top; unordered_map points_from_coords; for (int i = 0; i < N; i++) { int x, y; cin >> x >> y; Point *point = new Point(x, y); points.push_back(point); points_from_top.push_back(PointReferece(point, false)); points_from_left.push_back(PointReferece(point, true)); Coords c; c.x = x; c.y = y; points_from_coords.insert({c.id, point}); } sort(points_from_left.begin(), points_from_left.end()); sort(points_from_top.begin(), points_from_top.end()); int upper = 0, lower = N - 1; int nodes_left = N; int i = 0; for (; nodes_left > 4; i++) { Point *point = points_from_left[i].point; if (point->visited) continue; point->visited = true; nodes_left--; while (points_from_top[upper].point->visited) upper++; while (points_from_top[lower].point->visited) lower--; Point *B = points_from_top[lower].point; Point *D = points_from_top[upper].point; Coords c = find_fourth_of_rect(point, B, D); Point *C = points_from_coords.at(c.id); B->visited = true; D->visited = true; C->visited = true; nodes_left -= 3; } vector unvisited_points; for (; i < N; i++) { if (!points_from_left[i].point->visited) unvisited_points.push_back(points_from_left[i].point); } cout << (long long)sqrt(find_area_of_rect(unvisited_points[0], unvisited_points[1], unvisited_points[2])) << endl; return 0; }