Data Structures & AlgorithmsModerateCodeforces Div 2 D · ICPC regional
An undirected graph has the vertices C, E, L, M, T and the edges L–E, L–T, M–C, E–C, C–T. In how many ways can each vertex be given one of 3 colours (colours are labelled, and no two adjacent vertices may share a colour)?
- A. 72
- B. 48
- C. 36
- D. 243
Correct answer: C. 36
Count the proper 3-colourings by backtracking over the vertices; there are 36. Forgetting the edges gives 243, and subtracting each edge's monochromatic colourings once (no overlaps) gives -162.
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
- A directed acyclic graph has the vertices A, F, H, I, K, Q, R and the edges A→H, Q→A, Q→F, Q→H, R→F, F→H, F→K, F→I. A topological order…
- A tree has the vertices A, E, H, P, R, S, T, U, W, Y and the edges H–T, T–E, T–A, E–P, T–Y, A–R, Y–S, R–U, U–W. A set D dominates the tree…
- An undirected connected graph on 6 vertices has the edges (weights in brackets, all distinct): H–E (26), O–E (23), B–O (5), V–U (8), V–B…
- A tree has the vertices B, E, K, L, N, P, Y, Z and the edges N–E, N–B, E–L, N–K, E–Z, L–P, N–Y. What is the minimum number of vertices…
- An undirected graph has the vertices F, I, N, P, X, Y and the edges F–X, F–P, P–Y, P–X, I–Y, F–I, F–Y, F–N, N–I, I–X. What is the minimum…
- A directed graph has the vertices A, H, R, U, V, Y and the arcs V→A, A→H, A→R, U→R, H→R, Y→R, R→A, R→U, R→H. How many strongly connected…