C++ 250 ms
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    int minTimeToReach(vector<vector<int>>& moveTime) {\n        struct Room {\n            int  row   = 0;\n            int  col   = 0;\n            int  time  = 0;\n            bool first = false;\n            bool operator==(const Room& rhs) const {\n                return row == rhs.row and col == rhs.col;\n            }\n            bool operator<(const Room& rhs) const {\n                return time > rhs.time;\n            }\n        };\n\n        constexpr int visited = -1;\n        constexpr int dd[4][2] {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n        const int height = size(moveTime);\n        const int width = size(moveTime.front());\n        const Room end = {height - 1, width - 1};\n\n        auto is_valid = [&](const Room& room) {\n            if(room.row < 0 or room.row >= height or\n               room.col < 0 or room.col >= width) return false;\n            return true;\n        };\n\n        priority_queue<Room> rooms;\n        rooms.push({});\n        moveTime[0][0] = visited;\n        while(!rooms.empty()) {\n            const Room curr = rooms.top();\n            rooms.pop();\n            if(curr == end) return curr.time;\n            for(const auto& [dr, dc] : dd) {\n                Room next = {curr.row + dr, curr.col + dc};\n                if(is_valid(next) and moveTime[next.row][next.col] != visited) {\n                    int time = moveTime[next.row][next.col];\n                    next.time = (curr.time < time? time: curr.time) + (curr.first? 2: 1);\n                    next.first = curr.first ^ 1;\n                    rooms.push(next);\n                    moveTime[next.row][next.col] = visited;\n                }\n            }\n        }\n\n        return -1;\n    }\n};\n```
['C++']