[C++] Priority Queue (Shortest Path)
Code
# Code
```cpp []
class Solution {
public:
    int minTimeToReach(vector<vector<int>>& move_time) {
        int n = move_time.size();
        int m = move_time[0].size();
        vector<vector<int>> min_time(n, vector<int>(m, INT_MAX));
        min_time[0][0] = 0;
        vector<pair<int, int>> deltas({{-1, 0}, {0, -1}, {1, 0}, {0, 1}});
        priority_queue<tuple<int, int, int, int>, vector<tuple<int, int, int, int>>, greater<tuple<int, int, int, int>>> pq;
        pq.emplace(0, 0, 0, 1);
        while (!pq.empty()) {
            auto [pre_time, x, y, pre_dt] = pq.top();
            int cur_dt = pre_dt % 2 + 1;
            pq.pop();
            if (x == n - 1 && y == m - 1) {
                return pre_time;
            }
            for (const auto& [dx, dy]: deltas) {
                if (x + dx < 0 || y + dy < 0 || x + dx >= n || y + dy >= m) {
                    continue;
                }
                int cur_time = max(pre_time, move_time[x + dx][y + dy]) + pre_dt;
                if (min_time[x + dx][y + dy] > cur_time) {
                    min_time[x + dx][y + dy] = cur_time;
                    pq.emplace(cur_time, x + dx, y + dy, cur_dt);
                }
            }
        }
        return -1;
    }
};
```
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']