We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Roads and Libraries
Roads and Libraries
Sort by
recency
|
883 Discussions
|
Please Login in order to post a comment
Greetings! I wonder if anyone could help me figure out why I get failed tests, my approach is simply to count subgraphs, which should be enough to calculate least possible cost. Thanks!
I will share some intuition i used: - We need to look at every sub graph of the cities such that each sub graph is a (potential) connected component. - For each connected component, you can either buill one library per city and build no roads, or build one libaray and connect the rest of citis with mininum roads. There can be no in between that is optimum. - For n citis, you alway only need n - 1 roads.
my code with python. i dont know it fail in test case 7 how to debug def roadsAndLibraries(n, c_lib, c_road, cities): if c_road > c_lib: return c_lib * n
Branded lanyards can serve as a useful tool while exploring the concept of Roads and Libraries. As both are integral to connectivity, roads symbolize physical infrastructure, while libraries represent hubs of knowledge. Using lanyards, you can keep your IDs, keys, or event passes handy while navigating these essential spaces. Whether for educational trips or professional events, these lanyards are practical and serve as subtle promotional items to showcase your brand.
Guys , its a Basic disjoint set implemtation using krushkal;
The catch is it will pass all except 7 testcase due to typedef ,
we need to change all the int to long long , cause we multiply
So, we need to even change the long long inside main loop also instead of typecasting at result!!