beat 100%||classical dijkstra algorithm
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n\n    int minTimeToReach(vector<vector<int>>& mt) {\n// priority_queue--->{dist,{step,{curr_x,curr_y}}};\n        priority_queue<pair<int,pair<int,pair<int,int>>>, vector<pair<int,pair<int,pair<int,int>>>>, greater<pair<int,pair<int,pair<int,int>>>>> pq;\n        pq.push({0,{1 ,{0, 0}}});\n        int n = mt.size();\n        int m = mt[0].size();\n        vector<vector<int>> dp(n, vector<int>(m, INT_MAX));\n        int dx[] = {-1, 1, 0, 0};\n        int dy[] = {0, 0, -1, 1};\n        dp[0][0] = 0;\n        \n        while (!pq.empty()) {\n            auto node = pq.top(); pq.pop();\n            int ty = node.second.first;\n            int x = node.second.second.first;\n            int y= node.second.second.second;\n            int d = node.first;\n            \n            // If we reached the bottom-right corner\n            if (x == n - 1 && y == m - 1) return d;\n            \n            // Explore the four possible directions\n            for (int i = 0; i < 4; i++) {\n                int nx = x + dx[i];\n                int ny = y + dy[i];\n                \n                // Skip out-of-bounds cells\n                if (nx < 0 || ny < 0 || nx >= n || ny >= m) continue;\n                \n                // Calculate the time needed to reach the cell (nx, ny)\n                int curr = ty + max(d, mt[nx][ny]);\n                \n                // If this new time is less than the previously stored time\n                if (curr < dp[nx][ny]) {\n                    dp[nx][ny] = curr;\n                    pq.push({curr,{ty^3 ,{nx, ny}}});\n                }\n            }\n        }\n        \n        return dp[n - 1][m - 1];\n    }\n};\n\n```
['C++']