Line
发现,最终答案只有可能在 三者之间。
定义平行于 轴线段为 ,平行于 轴线段为 。
然后,我们考虑对 先左右平移,再上下平移。
-
对于左右平移,我们只用判断 横坐标覆盖的范围是否包括 的横坐标。
-
对于上下平移,我们只用判断 纵坐标多的覆盖范围是否包括 的纵坐标。
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
// freopen("6.in","r",stdin);
// freopen("6.out","w",stdout);
int t;
scanf("%lld",&t);
while(t--){
int x1F,x2F,x1L,x2L,y1F,y1L,y2L,y2F,ans=0;
scanf("%lld%lld%lld%lld",&x1F,&y1F,&x1L,&y1L);
scanf("%lld%lld%lld%lld",&x2F,&y2F,&x2L,&y2L);
if(y2F>y1L||y1L>y2L)
ans++;
if(x1F>x2F||x2F>x1L)
ans++;
cout<<ans<<endl;
}
return 0;
}