6.2 VJ C - Exercising Walk

#include<bits/stdc++.h>
#define ll long long
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll nl=1e5+5;
/*
题意:猫以[x,y]作为起点必须向左、右、下、上走a,b,c,d次,且不能超过[x1,x2]×[y1,y2]范围,判断能否成立
*/
int main()
{
    speed_up;
    int t;
    cin>>t;
    while(t--)
    {
        int a,b,c,d,x,y,x1,y1,x2,y2,l,r=1;
        cin>>a>>b>>c>>d;
        cin>>x>>y>>x1>>y1>>x2>>y2;
        if(x>x1||x<x2)//抵消掉一定可以向左或向右走的距离
        {
            l=min(a,b);
            a-=l;
            b-=l;
        }
        if(y>y1||y<y2)
        {
            l=min(c,d);
            c-=l;
            d-=l;
        }
        x1=x-x1;//求出原点到上下左右四个边界的距离,判断abcd会不会超出边界
        x2=x2-x;
        y2=y2-y;
        y1=y-y1;
        if(x1<a||x2<b||y1<c||y2<d)r=0;
        if(r==0)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }     return 0;
}
上一篇:池建强 Mac Tips


下一篇:5.23 Vj A - Candies