Back to Browse

11. Sparse Grids & Hash Map Traversal | BFS (Codeforces King's Path)

69 views
May 17, 2026
19:30

Continuing Phase 3: Implicit Graphs. In this lecture, we tackle Codeforces "King's Path" and confront the Memory Limit Exceeded (MLE) trap. When a problem features a grid size of 10^9 X 10^9, allocating a standard 2D array is mathematically impossible. We bypass this entirely by constructing a sparse grid. By utilizing std::map (or std::unordered_map), we track only the explicitly allowed segments, dynamically building our graph structure in memory only as we traverse it. This is a crucial technique for navigating infinite or hyper-massive state spaces. πŸ”— Problem Link: https://codeforces.com/contest/242/problem/C πŸ‘‹ π–πžπ₯𝐜𝐨𝐦𝐞 𝐭𝐨 𝐭𝐑𝐞 𝐜𝐑𝐚𝐧𝐧𝐞π₯!⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ ⁣⁣⁣⁣⁣⁣ I create content on Competitive Programming, Data Structures & Algorithms (DSA), and now Software Development with Go. If you find this video helpful, don’t forget to: πŸ‘ Like the video πŸ’¬ Comment your doubts/questions (I reply to everyone!) πŸ”” Subscribe and turn on notifications to never miss upcoming tutorials ⁣⁣⁣⁣⁣⁣ πŸ“Œ π‚π¨π§π§πžπœπ­ 𝐰𝐒𝐭𝐑 𝐦𝐞:⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ ⁣⁣⁣⁣⁣⁣ 🐦 X: https://x.com/Yash_Poonia_ πŸ’Ό LinkedIn: https://www.linkedin.com/in/yashpoonia/ πŸ’» GitHub: https://github.com/yash7xm/ 🌐 Discord: https://discord.gg/dAp2PbKFpV #BFS #CompetitiveProgramming #GraphTheory #Codeforces #Algorithms #Cplusplus #SoftwareEngineering

Download

0 formats

No download links available.

11. Sparse Grids & Hash Map Traversal | BFS (Codeforces King's Path) | NatokHD