C++ DFS
```\nclass Solution {\npublic:\n    vector> pacificAtlantic(vector>& matrix) {\n        vector> r;\n        int m = matrix.size();\n        if (m == 0)\n       
```\nclass Solution {\npublic:\n    vector<pair<int, int>> pacificAtlantic(vector<vector<int>>& matrix) {\n        vector<pair<int, int>> r;\n        int m = matrix.size();\n        if (m == 0)\n            return r;\n        int n = matrix[0].size();\n        if (n == 0)\n            return r;\n        vector<vector<bool>> pacific(m, vector<bool>(n));\n        vector<vector<bool>> atlantic(m, vector<bool>(n));\n        \n        for (int i = 0; i < m; i++) {\n            dfs(matrix, pacific, i, 0);\n            dfs(matrix, atlantic, i, n-1);\n\n        }\n        for (int j = 0; j < n; j++) {\n            dfs(matrix, pacific, 0, j);\n            dfs(matrix, atlantic, m-1, j);\n        }\n\n        \n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                if (pacific[i][j] && atlantic[i][j])\n                    r.push_back(make_pair(i,j));\n            }\n        }\n        return r;\n    }\n    \n    void dfs(vector<vector<int>>& matrix, vector<vector<bool>>& visited, int i, int j) {\n        int m = matrix.size();\n        int n = matrix[0].size();\n\n        visited[i][j] = true;\n        //up\n        if (i-1 >= 0 && visited[i-1][j] != true && matrix[i-1][j]>=matrix[i][j])\n            dfs(matrix, visited, i-1, j);\n        //down\n        if (i+1 < m && visited[i+1][j] != true && matrix[i+1][j]>=matrix[i][j])\n            dfs(matrix, visited, i+1, j);\n        //left\n        if (j-1 >= 0 && visited[i][j-1] != true && matrix[i][j-1]>=matrix[i][j])\n            dfs(matrix, visited, i, j-1);\n        //right\n        if (j+1 <n && visited[i][j+1] != true && matrix[i][j+1]>=matrix[i][j])\n            dfs(matrix, visited, i, j+1);\n\n    }\n};
[]