A. Exercising Walk
指定各个移动方向的移动次数,终点就是确定的,所以只要判断终点在不在范围之内,多余的步数让猫反复横跳就行了。要注意如果边界x1==x2,那么猫就不能左右移动,y轴也同理
代码
#pragma GCC optimize(2)
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#define INF 1e18
#define x first
#define y second
typedef long long ll;
using namespace std;
inline void read(int &p)
{
p=0;int flag=1;char c=getchar();
while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
while(isdigit(c)) {p=p*10+c-'0';c=getchar();}p*=flag;
}
int q;
int a,b,c,d;
int x,y,lx,rx,dy,uy;
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
read(q);
while(q--){
cin>>a>>b>>c>>d;
cin>>x>>y>>lx>>dy>>rx>>uy;
x+=b-a;
y+=d-c;
if(lx==rx&&(a||b)){
printf("NO\n");
}
else if(uy==dy&&(c||d)){
printf("NO\n");
}
else if(x<=rx&&x>=lx&&y<=uy&&y>=dy){
printf("YES\n");
}
else printf("NO\n");
}
return 0;
}