Line

发现,最终答案只有可能在 0,1,20,1,2 三者之间。

定义平行于 xx 轴线段为 AA,平行于 yy 轴线段为 BB

然后,我们考虑对 AA 先左右平移,再上下平移。

  • 对于左右平移,我们只用判断 AA 横坐标覆盖的范围是否包括 BB 的横坐标。

  • 对于上下平移,我们只用判断 BB 纵坐标多的覆盖范围是否包括 AA 的纵坐标。

#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;
}
posted @ 2023-12-21 13:20  June_Failure  阅读(8)  评论(0)    收藏  举报  来源