Tag: graph algorithms
The BFS (Breadth First Search Algorithm) expands the children nodes level by level, which allows you find the shortest distance between source and every other vertices. However, the graph …
There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys …
According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any …
The problem is from codeforces: http://www.codeforces.com/contest/278/problem/C The problem is graph-related and can be solved by many approaches. There is one exception case that you need to pay attention to: If …