TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

As usual, an electric power system is represented by an undirected graph G = (V, E) where V is a set of vertices containing all electric nodes of the system and E is a set of edges containing all transmission lines joining electric nodes. The power domination problem is to find a minimum placement of phase measurement units (abbreviated as PMUs) for observing whole vertices on a graph. The observation rules are as follows:

Observation Rule 1 (abbreviated as OR1):

A PMU on a vertex v observes v and all its neighbors.

Observation Rule 2 (abbreviated as OR2):

If an observed vertex u with degree d > 1 has only one unobserved neighbor v, then v becomes observed as well.

A vertex set S where PMUs are placed is a power dominating set (abbreviated as PDS) if all vertices in graph G can be observed either by OR1 initially or by OR2 recursively. The power domination number of G, denoted by γP(G), is the cardinality of a PDS which has the minimum number of vertices among all PDSs in G. A PDS of G with the minimum cardinality is called a γP(G)-set. For example, a path P5 is shown in Figure 1. If a PMU is placed at v1 (the gray vertex), then it observes v1 itself and its neighbor v2 (the slash vertex) by OR1. Next, the observed vertex v2 has only one unobserved neighbor v3 (a backslash vertex), then v3 becomes observed by OR2. By the same way, v4 and v5 will be observed in turn. Therefore, γP(P5) = 1 and the vertex set S = {v1} is a γP(P5)-set.

Let Gn,m be an n × m grid with m n ≥ 1. The vertex set V(Gn,m) = {(x, y) | 1 ≤ x n and 1 ≤ ym} and two vertices (x1, y1) and (x2, y2) are adjacent if and only if |x1x2| + |y1y2| = 1. Each vertex is labeled by x + (y − 1) ∗ n. For example, a G7,8 is shown in Figure 2(a).

Due to the considerations of cost saving, security policy, and other factors, we consider a forbidden set F where any PMU is disallowed to place. You have to findall γP(Gn,m)-sets in Gn,m by considering a forbidden set F. For example, see Figure 2(b), a vertex set S = {39, 44} is a γP(G7,8)-set by considering the forbidden set F = {17, 18, 19, 24, 26, 31, 33, 38, 40}. The reason is that, by OR1, vertices 32, 37, 38, 39, 40, 43, 44, 45, 46, and 51 are observed. Since vertex 45 has only one unobserved neighbor, vertex 52 becomes observed by OR2. Next, vertex 51 has only one unobserved neighbor, vertex 50 becomes observed by OR2. By using OR2 recursively, we can find that all the remaining vertices 53, 47, 54, 48, 55, 56, · · · , can be observed in turn. Consequently, the vertex set S = {39, 44} is a γP(G7,8)-set. Note that vertex set S = {9, 22, 37} is also a PDS. However, it is not a γP(G7,8)-set.

Input Format

The first line of the input file contains two integers n and m which denote the numbers of columns and rows, respectively, in Gn,m. Both of n and m are less than 20. The second line contains a forbidden set F. You have to find all γ(G)-sets of the given G.

Output Format

Output all γP(Gn,m)-sets line by line (one γP(Gn,m)-set a line) in the lexicographical order.

Sample Input 1

7 8 
17 18 19 24 26 31 33 38 40 

Sample Output 1

39 44 
39 48 
39 52 
39 54 

Hints

Problem Source

Migrated from old NTUJ.

NCPC2007

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 30000 65536 200