A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:
-2: turn left 90 degrees
-1: turn right 90 degrees
1 <= x <= 9: move forward x units
Some of the grid squares are obstacles.
The i-th obstacle is at grid point (obstacles[i][0], obstacles[i][1])
If the robot would try to move onto them, the robot stays on the previous grid square instead (but still continues following the rest of the route.)
Return the square of the maximum Euclidean distance that the robot will be from the origin.

Example 1:
Input: commands = [4,-1,3], obstacles = []
Output: 25
Explanation: robot will go to (3, 4)

Example 2:
Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]]
Output: 65
Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8)

Note:

1. 0 <= commands.length <= 10000
2. 0 <= obstacles.length <= 10000
3. -30000 <= obstacle[i][0] <= 30000
4. -30000 <= obstacle[i][1] <= 30000
5. The answer is guaranteed to be less than 2 ^ 31.

1. 首先应该确定目前行进的方向，我用(1,-1,-2,2)这四个值分别代表上下左右,dire = 1代表目前向上行进，故初始化dire = 1
2. 当commands[i] = -2 or -1时，改变dire的值，这跟dire当前的值有关，具体方法于思路中说
3. 因为每次行进的距离不超过10，那么最多也就走90000步，我们完全可以每一步都判断其是否被一个obstacles所阻挡，但是每次比较一个元祖是不是在集合中也太蠢了，所以稍微处理一下，我们用两个字典记录obstacles，例如，dx[x1]代表一个列表，列表里面记录所有横坐标为x1的点的纵坐标,dy[y1]同理
4. `注意，这道题是要求整个过程中达到的最大的欧拉距离，并不是最后的距离，所有每移动一次就要比较一次，我就是没看到这一点，做了特别特别久，都不知道哪里错了！`

1. 我们用一个directions = {1:[-2,2], -1:[2,-2], -2:[-1,1], 2:[1,-1]}记录方向的变换，对于directions[x]，x代表当前方向，directions[x][0]表示向左转之后的方向，directions[x][1]代表向右转之后的方向
2. 用position=[x,y]记录此时的位置，每进行一次移动就记录一次
3. 别看代码这么长，其实后面的代码都是一样的（只跟方向有关），因为太恶心了我也懒得整合了