81 lines
2.0 KiB
C++
81 lines
2.0 KiB
C++
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
struct xy {
|
||
|
int x[5], y[5];
|
||
|
} a[2];
|
||
|
|
||
|
int hx(int a, int b)
|
||
|
{
|
||
|
return a < b ? a : b;
|
||
|
}
|
||
|
int hd(int a, int b)
|
||
|
{
|
||
|
return a > b ? a : b;
|
||
|
}
|
||
|
|
||
|
void cfind()
|
||
|
{
|
||
|
for (int i = 1; i <= 4; i++) {
|
||
|
if (a[0].x[i] >= a[1].x[3] && a[0].x[i] <= a[1].x[4]) {
|
||
|
if (a[0].y[i] >= a[1].y[3] && a[0].y[i] <= a[1].y[4]) {
|
||
|
cout << "Y" << endl;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
a[1].x[3] = a[1].x[1];
|
||
|
a[1].y[3] = a[1].y[2];
|
||
|
a[1].x[4] = a[1].x[2];
|
||
|
a[1].y[4] = a[1].y[1];
|
||
|
a[0].x[3] = hx(a[0].x[1], a[0].x[2]);
|
||
|
a[0].y[3] = hx(a[0].y[2], a[0].y[1]);
|
||
|
a[0].x[4] = hd(a[0].x[1], a[0].x[2]);
|
||
|
a[0].y[4] = hd(a[0].y[2], a[0].y[1]);
|
||
|
for (int i = 1; i <= 4; i++) {
|
||
|
if (a[1].x[i] >= a[0].x[3] && a[1].x[i] <= a[0].x[4]) {
|
||
|
if (a[1].y[i] >= a[0].y[3] && a[1].y[i] <= a[0].y[4]) {
|
||
|
cout << "Y" << endl;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
cout << "N" << endl;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int n;
|
||
|
cin >> n;
|
||
|
for (int i = 1; i <= n; i++) {
|
||
|
for (int j = 1; j <= 2; j++) {
|
||
|
int cx, cy;
|
||
|
cin >> cx >> cy;
|
||
|
a[0].x[j] = cx + 100000;
|
||
|
a[0].y[j] = cy + 100000;
|
||
|
}
|
||
|
a[0].x[3] = a[0].x[1];
|
||
|
a[0].y[3] = a[0].y[2];
|
||
|
a[0].x[4] = a[0].x[2];
|
||
|
a[0].y[4] = a[0].y[1];
|
||
|
for (int j = 1; j <= 2; j++) {
|
||
|
int cx, cy;
|
||
|
cin >> cx >> cy;
|
||
|
a[1].x[j] = cx + 100000;
|
||
|
a[1].y[j] = cy + 100000;
|
||
|
}
|
||
|
a[1].x[3] = hx(a[1].x[1], a[1].x[2]);
|
||
|
a[1].y[3] = hx(a[1].y[2], a[1].y[1]);
|
||
|
a[1].x[4] = hd(a[1].x[1], a[1].x[2]);
|
||
|
a[1].y[4] = hd(a[1].y[2], a[1].y[1]);
|
||
|
// for(int j=1;j<=4;j++){
|
||
|
// cout<<a[0].x[j]<<","<<a[0].y[j]<<endl;
|
||
|
// }
|
||
|
// for(int j=1;j<=4;j++){
|
||
|
// cout<<a[1].x[j]<<","<<a[1].y[j]<<endl;
|
||
|
// }
|
||
|
cfind();
|
||
|
}
|
||
|
return 0;
|
||
|
}
|