Timed Tilt Final Cell
MediumSimulation · HRT
A sled rests on a floor plan grid, a list of equal-length strings where . is open and # is blocked. At second 0 it is still, on the open cell start = [row, col].
Each events[i] = [t, d] tilts the floor at second t toward d, one of "U", "D", "L", "R" or "S" (level). Until the next event, the sled moves one cell per second toward d whenever that cell is open and inside the grid, and otherwise stays put. Events are sorted by strictly increasing t.
Return the sled's [row, col] at second end_time. Row 0 is the top.
Example 1
- Input:
- grid = ["....", "..#.", "...."], start = [0, 0], events = [[1, "R"], [3, "D"], [5, "L"]], end_time = 6
- Output:
- [0, 1]
- Explanation
- The sled reaches (0, 2) at second 3. The D tilt is blocked by the wall below it, so it waits there until the L tilt moves it one cell.
Example 2
- Input:
- grid = ["...", "...", "..."], start = [0, 1], events = [[0, "D"], [5, "R"]], end_time = 5
- Output:
- [2, 1]
- Explanation
- An event at second 5 happens too late to move the sled by second 5.
Example 3
- Input:
- grid = ["...#."], start = [0, 0], events = [[3, "R"]], end_time = 1000000000
- Output:
- [0, 2]
Constraints
- 1 ≤
grid.length,grid[i].length ≤ 500 startis an open cell ofgrid- 0 ≤
events.length ≤ 100000 - 0 ≤
events[i][0] ≤ 1000000000 - 0 ≤
end_time≤ 1000000000