Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
An undirected connected graph on the vertices D, L, R, T, V has the edges D–V, L–R, D–T, V–R, L–T, L–V, V–T, L–D. How many spanning trees does it have? (A spanning tree is a set of edges that connects all vertices with no cycle.)
- A. 16
- B. 40
- C. 70
- D. 41
Correct answer: B. 40
The Matrix-Tree theorem gives the count as any cofactor of the Laplacian, here 40. Choosing any 4 of the 8 edges gives 70 sets, but most of them contain a cycle or leave a vertex out.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Each cell of a grid with 4 rows and 5 columns has an arrow: R = right, L = left, U = up, D = down. RUUUD RLDUL UDLDR RDDRU From a cell you…
- Starting from the integer 9, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- Two unmarked jugs hold 7 litres and 8 litres. Allowed operations: fill a jug completely, empty a jug completely, or pour one jug into the…
- Cities A, B, N, T, U are joined by roads with these travel costs: A–N 15, A–U 2, A–B 4, A–T 14, N–U 17, N–B 5, N–T 13, U–B 8, U–T 6, B–T…
- An undirected connected graph on the vertices D, U, W, X has the edges U–X, D–W, D–X, W–X, D–U. How many spanning trees does it have? (A…
- A connected undirected graph has the vertices B, M, R, T, U and the edges U–T, U–M, U–R, T–R, T–B, M–B, R–B. Parallel edges are allowed…