#include #include #include #include #include #include #include #include #include #include #include using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { int q; in >> q; for (int i = 0; i < q; i++) { int n; in >> n; vector> points; set xs; setys; for (int j = 0; j < n; j++) { double x, y; in >> x >> y; xs.insert(x); ys.insert(y); points.push_back({ x,y }); } if (n == 1 || n == 2) { out << "YES" << endl; continue; } else { if (xs.size() == 1 || ys.size() == 1) { out << "NO" << endl; continue; } bool is_ok = true; for (int j = 0; j < n; j++) { int x = points[j].first; int y = points[j].second; for (int k = 0; k < n; k++) { if (j == k) continue; for (int l = 0; l < n; l++) { if (j == l) continue; int x1 = points[k].first; int y1 = points[k].second; int x2 = points[l].first; int y2 = points[l].second; if (x > min(x1, x2) && x < max(x1, x2) && y > min(y1, y2) && y < max(y1, y2)) { is_ok = false; break; } } if (!is_ok) break; } if (!is_ok) break; } if (is_ok) { out << "YES" << endl; continue; } } out << "NO" << endl; } } }; void solve(std::istream& in, std::ostream& out) { out << std::setprecision(12); Solution solution; solution.solve(in, out); } #include #include int main() { ios_base::sync_with_stdio(0); cin.tie(0); istream& in = cin; ostream& out = cout; solve(in, out); return 0; }