有一个很明显的做法就是判断PointInPolygon 。枚举第二个矩形的点,是否在第一个矩形内,但是有bug

就是那种第二个矩形很大的那种,所以容易想到又枚举第一个矩形的点,看是否在第二个矩形里。

但是还是有bug。就是那种十字架的那种,大家都不属于大家,但是他们的对角线是相交的,判断对角线即可。

其实这题可以倒过来做。判断不相交。

1、如果第一个矩形的最大的x还比第二个矩形的最小的x小,那么永远不能相交。(画个图就可以)

2、.....类似的。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
void work() {
int mi_x[];
int mi_y[];
int mx_x[];
int mx_y[];
int xx1, yy1, xx2, yy2;
for (int i = ; i <= ; ++i) {
cin >> xx1 >> yy1 >> xx2 >> yy2;
mi_x[i] = min(xx1, xx2);
mx_x[i] = max(xx1, xx2);
mi_y[i] = min(yy1, yy2);
mx_y[i] = max(yy1, yy2);
}
if (mi_x[] > mx_x[] || mx_x[] < mi_x[] ||
mx_y[] < mi_y[] || mi_y[] > mx_y[]) {
cout << "Miss" << endl;
} else {
cout << "Hit" << endl;
}
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
int t;
cin >> t;
while (t--) work();
return ;
}

最新文章

  1. asp.net中缓存的使用介绍一
  2. HTML中网页超链接设计
  3. 【poj2778-DNA Sequence】AC自动机+矩阵乘法
  4. ThreadLocal模式探索
  5. 【转】linux线程模型
  6. hibernate的id生成策略
  7. css3属性——border-radius用法
  8. c语言学习基础:[1]开发工具介绍
  9. Navicat for MySQL11--使用经验
  10. vi 编辑器笔记
  11. JDK8的新特性——Lambda表达式
  12. 权限认证 cookie VS token
  13. bash shell while语法
  14. JavaScript进阶(一)抽离公共函数
  15. github密钥
  16. centos7_ linux : Nginx安装手册
  17. Delphi自动适应屏幕分辨率的属性
  18. A crawler that sent a DELETE request to every resource it encountered
  19. StringDemo
  20. [转]如何远程连接运行OpenGL/Cuda 等GPU程序

热门文章

  1. Mac开发快速入门
  2. 【转载】Unity3D的断点调试功能
  3. Web前端行业的了解
  4. keras中的Flatten和Reshape
  5. codevs 2456栅栏
  6. Win32编程点滴5 - 响应ActiveX控件的事件
  7. div显示2列
  8. dubbo项目中包的依赖说明
  9. 1、css选择器
  10. Flutter实战视频-移动电商-26.列表页_使用Provide控制子类-2