#include #include #include using namespace std; bool allOnRectangle(const vector> &points); int main() { int queryCount; cin >> queryCount; for (int i=0; i> pointCount; vector> points; points.reserve(pointCount); for (int i=0; i> x >> y; points.emplace_back(x,y); } if (allOnRectangle(points)) { cout << "YES\n"; } else { cout << "NO\n"; } } return 0; } bool allOnRectangle(const vector> &points) { if (points.size() <= 2) { //always true here return true; } int minX{points[0].first}, minY{points[0].second}; int maxX{points[0].first}, maxY{points[0].second}; for (int i=1; i maxX) { maxX = x; } if (y < minY) { minY = y; } else if (y > maxY) { maxY = y; } } // cout << "minX " << minX << ", maxX " << maxX << ", minY " << minY << ", maxY " << maxY << '\n'; for (const auto &xyPoint : points) { if (xyPoint.first == maxX || xyPoint.first == minX) { //This is always ok continue; } if (xyPoint.second == maxY || xyPoint.second == minY) { //This is always ok continue; } return false; } return true; }