#include #include #include #include #include using namespace std; struct Point { long long x; long long y; bool removed = false; }; int removePoint(std::vector &points, size_t startIndex, bool Dir) { while(points[startIndex]->removed == true){ if (Dir == true) { startIndex++; } else { startIndex--; } } // points[startIndex]->removed = true; // if (Dir == true) // { // startIndex++; // } // else // { // startIndex--; // } return startIndex; } long long dstSqared(Point &a, Point &b){ return (a.x - b.x)* (a.x - b.x) + (a.y - b.y) * (a.y - b.y); } int main() { std::ios::sync_with_stdio(false); std::cin.tie(NULL); int cnt; std::cin >> cnt; assert(cnt % 4 == 0); std::vector points; std::vector xSorted, ySorted; points.resize(cnt); xSorted.resize(cnt); ySorted.resize(cnt); for (int i = 0; i < cnt; ++i) { std::cin >> points[i].x; std::cin >> points[i].y; points[i].removed = false; xSorted[i] = &points[i]; ySorted[i] = &points[i]; } std::sort(xSorted.begin(), xSorted.end(), [](const Point *lhs, const Point *rhs) { return lhs->x < rhs->x; }); std::sort(ySorted.begin(), ySorted.end(), [](const Point *lhs, const Point *rhs) { return lhs->y < rhs->y; }); size_t xMin = 0, yMin = 0, xMax = cnt - 1, yMax = cnt - 1; for (int i = 0; i < cnt / 4 - 2; ++i) { if (!(xSorted[xMin] != ySorted[yMin] && xSorted[xMin] != ySorted[yMax] && xSorted[xMax] != ySorted[yMax] && xSorted[xMax] != ySorted[yMin])) { xMin = removePoint(xSorted, xMin, true); yMin = removePoint(ySorted, yMin, true); xMax = removePoint(xSorted, xMax, false); yMax = removePoint(ySorted, yMax, false); xSorted[xMin]->removed = true; xSorted[xMax]->removed = true; ySorted[yMin]->removed = true; ySorted[yMax]->removed = true; } xMin = removePoint(xSorted, xMin, true); yMin = removePoint(ySorted, yMin, true); xMax = removePoint(xSorted, xMax, false); yMax = removePoint(ySorted, yMax, false); xSorted[xMin]->removed = true; xSorted[xMax]->removed = true; ySorted[yMin]->removed = true; ySorted[yMax]->removed = true; } // for(auto & pt : xSorted){ // cout << pt->x << " " << pt->y << " "<< pt->removed << endl; // } // cout << "y---------------------------" << endl; // for(auto & pt : ySorted){ // cout << pt->x << " " << pt->y << " "<< pt->removed << endl; // } std::vector resPoints; int i = 0; for(auto &pt : points){ if(pt.removed == false){ resPoints.push_back(&pt); i++; } if(i == 4)break; } // int i = 4; // while (i < 4) // { // if (xSorted[xMin]->removed == false) // { // i++; // resPoints.push_back(xSorted[xMin]); // } // xMin++; // } // cout << resPoints.size() << endl; assert(resPoints.size() == 4); // for (auto&p: points) { // std::cout << p.x; // } Point refPt = *resPoints[0]; vector dst2; for(int i = 1; i < 4; ++i){ long long dst = dstSqared(refPt, *resPoints[i]); // cout << dst << endl; dst2.push_back(dst); } int max = 0; for(int i = 0; i < 3; i++){ if(dst2[max] < dst2[i]){ max = i; } } dst2.erase(dst2.begin()+max); double a =sqrt( dst2[0]); double b = sqrt(dst2[1]); double res = round(a * b); cout << (long long)res << endl; }