#P16149. [ICPC 2017 NAIPC] Maximum Color Clique

[ICPC 2017 NAIPC] Maximum Color Clique

题目描述

You found a complete, undirected graph with nn nodes, labeled 1..n1..n. Each edge has a color. For simplicity, each color is identified by a number between 1 and 300 inclusive. Interestingly, you noticed that for each and every simple cycle in this graph, there are two adjacent edges on this cycle which have the same color.

For each non-empty subset of nodes in graph SS, let f(S)f(S) denote the size of the maximum subset of nodes you can choose from SS such that all edges between the chosen nodes are the same color. Compute the sum of f(S)f(S) over all non empty subsets SS of nodes in the graph.

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input will contain a single integer nn (1n3001 \leq n \leq 300), which is the number of nodes in the graph.

The next nn lines will each contain nn integers cc (0c3000 \leq c \leq 300), which is a matrix representing the colors of the edges, where c[x,y]c[x, y] is the color of the edge between node xx and node yy. It is guaranteed that the values on the diagonal will be 0 (c[x,x]=0c[x, x] = 0), since there is no edge from a node to itself. It is also guaranteed that the matrix is symmetric and the off-diagonal colors range from 1 to 300 (1c[x,y]=c[y,x]3001 \leq c[x, y] = c[y, x] \leq 300 for xyx \neq y).

输出格式

Output a single integer, which is the sum of f(S)f(S) over all non empty subsets SS of nodes in the graph. Since this number may be very large, output it modulo 109+710^9 + 7.

4
0 1 1 1
1 0 2 2
1 2 0 3
1 2 3 0
26
5
0 300 300 300 300
300 0 300 300 300
300 300 0 300 300
300 300 300 0 300
300 300 300 300 0
80