Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional
An undirected graph has the vertices C, J, L, Q, W and the edges W–L, J–C, L–C, J–Q, Q–L, W–C, W–J, W–Q. How many simple cycles does it contain (a cycle visits distinct vertices and returns to its start; cycles that use the same edge set are the same cycle)?
- A. 4
- B. 3
- C. 14
- D. 13
Correct answer: D. 13
Enumerate edge subsets in which every vertex has degree 0 or 2 and the edges form one connected cycle: there are 13. The cyclomatic number m − n + 1 = 4 counts independent cycles, which is not the same count, and there are 4 triangles.
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 tree on the vertices B, E, G, S, W has the arcs W→E, S→E, B→W, W→G (each undirected edge is directed as shown). You may reverse the…
- The directed acyclic graph has the vertices C, F, G, K, N, T, W and the arcs C→F, W→C, G→N, G→K, N→F, K→F, T→W, W→F, T→F, G→T, K→C, T→K…
- A directed acyclic graph has the vertices B, I, M, Q, R and the arcs B→Q, B→R, I→Q, I→R, I→M, Q→M. Two players alternately move a single…
- Starting from the integer 15, one operation either adds 1, subtracts 1, or doubles the current value. Values may be any non-negative…
- A tree has vertices with weights in brackets: A[5], Z[10], I[13], N[7], L[8], M[15], D[8], R[12], C[9]. The edges are A–Z, Z–I, I–N, A–L…
- An undirected graph has the vertices B, I, L, N, Q, Y, Z and the edges N–L, N–Y, N–Q, N–I, N–Z, L–Y, L–Q, B–I, B–Z. What is its chromatic…