[python] simple
\nclass Solution:\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        q=deque([([0,1],0,0)])\n        def inb(p):return p[0]>=0 and p[0]<len(gri
```\nclass Solution:\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        q=deque([([0,1],0,0)])\n        def inb(p):return p[0]>=0 and p[0]<len(grid) and p[1]>=0 and p[1]<len(grid[0]) and grid[p[0]][p[1]]==0\n        u=set()\n        while q:\n            p,v,c=q.popleft()\n            if p[0]==len(grid)-1 and p[1]==len(grid[0])-1 and v==0:return c\n            k=(p[0],p[1],v)\n            if k in u:continue\n            u.add(k)\n            if v==0:\n                pn=[p[0],p[1]+1]\n                if inb(pn):q.append((pn,v,c+1))\n                pn=[p[0]+1,p[1]]\n                if inb(pn) and inb([p[0]+1,p[1]-1]):q.append((pn,v,c+1))\n                pn=[p[0]+1,p[1]-1]\n                if inb(pn) and inb([p[0]+1,p[1]]):q.append((pn,1,c+1))\n            elif v==1:\n                pn=[p[0]+1,p[1]]\n                if inb(pn) and grid[pn[0]][pn[1]]!=1:q.append((pn,v,c+1))\n                pn=[p[0],p[1]+1]\n                if inb(pn) and inb([p[0]-1,p[1]+1]):q.append((pn,v,c+1))\n                pn=[p[0]-1,p[1]+1]\n                if inb(pn) and inb([p[0],p[1]+1]):q.append((pn,0,c+1))\n        return -1\n```
[]