Hướng dẫn giải của Piccôlô Chui Ra Khỏi Hang


Chỉ dùng lời giải này khi không có ý tưởng, và đừng copy-paste code từ lời giải này. Hãy tôn trọng người ra đề và người viết lời giải.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.

Consider a platform ~i~, we'll check from all of the platform ~j < i~, which can reach ~i~ on the opposite wall.

To check which platform can reach ~i~, we keep track of the area from where Piccolo can jump to the platform ~i~ as we traverse from ~i-1~ to the first platform. This area can be defined by two boundaries: The left boundary from ~i~'s edge to some ~L~-type platform's edge and the right boundary from ~i~'s edge to some ~R~-type platform's edge. If a platform ~j < i~ on the opposite side intersects strictly within the current boundaries, then Piccolo can jump from platform ~j~ to platform ~i~.

As we traverse ~i~ platform from bottom to top, we keep track of the optimal answer for each platform as well.

Complexity: ~O(n^2)~


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.