Seven Segment Graph
Time limit1sMemory limit128 MB
Given a graph, list every digit and subdivision degree whose seven-segment display graph has the same shape.
- Level
Medium7 of 10
- Topics
- Graph, Math, Brute force
- Solved
- No attempts yet
Problem
A seven segment display shows one digit by turning seven segments on and off. From here on, seven segment display is shortened to SSD.
The seven segments have the names and positions below. The DP segment for the decimal point is not used in this problem.
AAAA
F B
F B
GGGG
E C
E C
DDDD
The segments meet at six endpoints. Call the top left, top right, middle left, middle right, bottom left and bottom right endpoints LT, RT, LM, RM, LB and RB. Each segment joins the two endpoints below.
An SSD lights the following segments to show the digits through .
- : A, B, C, D, E, F
- : B, C
- : A, B, G, E, D
- : A, B, C, D, G
- : B, C, F, G
- : A, C, D, F, G
- : A, C, D, E, F, G
- : A, B, C
- : A, B, C, D, E, F, G
- : A, B, C, D, F, G
The display of one digit can be read as a graph. Take the endpoints of the lit segments as nodes and the lit segments themselves as edges, and one graph comes out. Endpoints of segments that stay off are not nodes. The graph obtained this way is called the SSD graph of degree .
The SSD graph of degree () is built by splitting every edge of the degree SSD graph into edges and inserting new nodes in between. In the degree SSD graph, for example, one original edge turns into two edges with one new node between them.
You are given a graph with nodes and edges. Write a program that finds every SSD graph with the same shape as the given graph, that is, every SSD graph isomorphic to it, and reports its digit and degree.
Input
The first line contains the number of test cases (). The first line of each test case contains the number of nodes () and the number of edges (). Each of the next lines contains the numbers and of the two nodes an edge joins. Nodes are numbered from to . No edge is given twice, and no edge has equal to .
Output
For each test case, print Case X: Y on the first line, where is the test case number and is the number of possible (digit, degree) pairs. On each of the next lines, print one possible digit and degree separated by a space. Print them in increasing order of digit, and in increasing order of degree when the digit is the same. Print one blank line between test cases.