#include #include #include #include #include using namespace std; struct Pine { int x[3]; int y[3]; }; inline int Max(int arr[]) { return distance(arr, max_element(arr, arr + 3)); } inline int Min(int arr[]) { return distance(arr, min_element(arr, arr + 3)); } inline bool Equal(double a, double b) { return fabs(a - b) < 0.000001; } int main() { int n; cin >> n; vector pines; for (int i = 0; i < n; i++) { Pine p; cin>> p.x[0] >> p.x[1] >> p.x[2] >> p.y[0] >> p.y[1] >> p.y[2]; pines.emplace_back(p); } for (Pine p : pines) { // 真ん中が最大か最小 if (p.x[0] != p.x[1] && p.x[1] != p.x[2] && p.x[0] != p.x[2]) { if (Max(p.x) == 1 || Min(p.x) == 1) { cout << "YES" << endl; continue; } } // 真ん中と左右どちらかが同じ値かつ増加量も同じ if ((p.x[0] == p.x[1] && p.y[0] == p.y[1]) || (p.x[1] == p.x[2] && p.y[1] == p.y[2]) || (p.x[0] == p.x[2] && p.y[0] == p.y[2])) { cout << "NO" << endl; continue; } // 値がすべて一致するタイミングで左右の大小が入れ替わる double n1 = static_cast(p.x[0] - p.x[1]) / (p.y[1] - p.y[0]); double n2 = static_cast(p.x[1] - p.x[2]) / (p.y[2] - p.y[1]); if (Equal(n1, n2)) { cout << "NO" << endl; continue; } bool gt = p.x[0] > p.x[2]; // 真ん中と左右どちらかの値が同じ場合 if (p.x[0] == p.x[1] || p.x[1] == p.x[2]){ if (p.x[0] > p.x[2] && p.y[0] > p.y[2]) { gt = true; } else if (p.x[0] < p.x[2] && p.y[0] < p.y[2]) { gt = false; } } else if (p.x[0] == p.x[2]) { gt = p.y[0] < p.y[2]; } int step = 2020; p.x[0] += p.y[0] * step; p.x[1] += p.y[1] * step; p.x[2] += p.y[2] * step; // 門松列になった if (Max(p.x) == 1 || Min(p.x) == 1) { cout << "YES" << endl; continue; } // 左右の大小が入れ替わらなかった if (gt == (p.x[0] > p.x[2])) { cout << "NO" << endl; } // 左右の大小が入れ替わった else { cout << "YES" << endl; } } return 0; }