Back to Browse

8. Multi-Source Spanning Forests & Edge Pruning | BFS (Codeforces Police Stations)

69 views
May 15, 2026
14:35

Closing out Phase 2 with a masterclass in graph reduction. In this lecture, we tackle Codeforces "Police Stations" and explore how a Multi-Source BFS inherently generates a shortest-path spanning forest. By seeding the queue with all police stations and expanding outward simultaneously, we naturally claim cities optimally. By tracking which edges are used during this "domain expansion," we isolate the absolute minimum roads required to keep the network connected to the stations. Any edge ignored by the BFS is mathematically redundant and safely deleted. We also break down why the distance constraint $d$ provided in the problem description is actually a clever competitive programming red herring. πŸ”— Problem Link: https://codeforces.com/contest/796/problem/D πŸ‘‹ π–πžπ₯𝐜𝐨𝐦𝐞 𝐭𝐨 𝐭𝐑𝐞 𝐜𝐑𝐚𝐧𝐧𝐞π₯!⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ ⁣⁣⁣⁣⁣⁣ 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.

8. Multi-Source Spanning Forests & Edge Pruning | BFS (Codeforces Police Stations) | NatokHD