题目大意:
就是给出平面中n个点, 然后给出行走路径问最多走多少步不会出现不能到达以及碰撞的情况
大致思路:
首先如果只考虑上下左右走的话很明显用Set来存坐标然后用upper_bound查询两个点之间是否有被拦截即可
那么斜着走的话, 只需要将坐标轴旋转, 例如逆时针旋转45度于是(x, y)在新坐标系中映射的位置是(x - y, x + y)(放大了sqrt(2)倍
于是就和上下左右一样了
代码如下:
Result : Accepted Memory : 13576 KB Time : 590 ms
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define mp make_pair
#define x first
#define y second
#define maxn 100010
int n;
pair<int, int > p[maxn];
set<pair<int, int> > Sx;
set<pair<int, int> > Sy;
set<pair<int, int> > Gx;
set<pair<int, int> > Gy;
set<pair<int, int>