Split Cell into 4 Sections
\nfrom collections import *\n\nclass Solution:\n    def regionsBySlashes(self, grid: List[str]) -> int:\n        n = len(grid)\n        graph = defaultdict(list
```\nfrom collections import *\n\nclass Solution:\n    def regionsBySlashes(self, grid: List[str]) -> int:\n        n = len(grid)\n        graph = defaultdict(list)\n        for i in range(n):\n            for j in range(n):\n                for x, y, s, p in [(i, j - 1, 3, 1), (i - 1, j, 0, 2), (i, j + 1, 1, 3), (i + 1, j, 2, 0)]:\n                    if 0 <= x < n and 0 <= y < n:\n                        graph[(i, j, s)].append((x, y, p))\n                        graph[(x, y, p)].append((i, j, s))\n                ops = []\n                if grid[i][j] == \'/\' or grid[i][j] == \' \':\n                    ops.extend([(2, 1), (3, 0)])\n                if grid[i][j] == \'\\\\\' or grid[i][j] == \' \':\n                    ops.extend([(0, 1), (2, 3)])\n                for x, y in ops:\n                    graph[(i, j, x)].append((i, j, y))\n                    graph[(i, j, y)].append((i, j, x))\n        res = 0\n        v = set()\n        def dfs(x):\n            v.add(x)\n            for y in graph.get(x, []):\n                if y not in v:\n                    dfs(y)\n        for x in graph:\n            if x not in v:\n                res += 1\n                dfs(x)\n        return res\n```
['Python']