Fragile
SRM 648 · 2015-01-29 · by evima
Problem Statement
You are given two
- The graph has exactly N vertices, labeled from 0 to N-1. Each vertex has a unique label.
- The graph has no loops (edges connected at both ends to the same vertex) and no more than one edge between any two different vertices.
- The graph has exactly K bridges (edges whose deletion increases its number of connected components).
Find and return the number of these graphs modulo 1,000,000,007.
Notes
- Two graphs are considered different if and only if there exists a pair of vertices such that one of the graphs contains an edge between them, and the other does not.
Constraints
- N will be between 1 and 50, inclusive.
- K will be between 0 and N-1, inclusive.
3 2 Returns: 3
The following three graphs satisfy the conditions:
4 0 Returns: 15
The following 15 graphs satisfy the conditions:
5 2 Returns: 195
The following is some of the graphs that satisfy the conditions: Here, bridges are painted in brown, and "x n" represents that there are n graphs that are isomorphic to that graph.
50 25 Returns: 353637389
1 0 Returns: 1
Submissions are judged against all 109 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Fragile with a public method int countGraphs(int N, int K) · 109 test cases · 2 s / 256 MB per case