Logo
(追記) (追記ここまで)

19467번 - Graph Coloring 2 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB4711975.000%

문제

You are given an undirected graph with $n$ vertices numbered 0ドル$ through $n - 1$. Obviously, the set of vertices have 2ドル^n - 1$ non-empty subsets. For a non-empty subset $S,ドル a proper coloring of $S$ is a way to assign each vertex in $S$ a color, so that no two vertices in $S$ with the same color are directly connected by an edge. Assume we used $k$ different kinds of colors in a proper coloring. The chromatic number of subset $S$ is the minimum possible $k$ among all the proper colorings of $S$.

Now your task is to compute the chromatic number of every non-empty subset of $n$ vertices.

입력

The first line contains an integer $T$. Then $T$ test cases follow.

The first line of each test case contains an integer $n$. Each of then next $n$ lines contains a string consisting of '0' and '1'. For 0ドル \le i \le n - 1$ and 0ドル \le j \le n - 1,ドル if the $j$-th character of the $i$-th line is '1', then vertices $i$ and $j$ are directly connected by an edge, otherwise they are not directly connected.

The $i$-th character of the $i$-th line is always '0'. The $i$-th character of the $j$-th line is always the same as the $j$-th character of the $i$-th line.

For all test cases, 1ドル \le n \le 18$. There are no more than 100ドル$ test cases with 1ドル \le n \le 10,ドル no more than 3ドル$ test cases with 11ドル \le n \le 15,ドル and no more than 2ドル$ test cases with 16ドル \le n \le 18$.

출력

For each test case, print an integer on a separate line. This integer is determined as follows: We define the identity number of subset $S$ as $\mathit{id} (S) = \sum_{v \in S} 2^v$. Let the chromatic number of $S$ be $f_{\mathit{id} (S)}$. You need to output $$\left(\sum\limits_{\mathit{id} (S) = 1}^{2^n - 1} f_{\mathit{id} (S)} \cdot 233^{\mathit{id} (S)}\right) \bmod 2^{32}\text{.}$$

제한

예제 입력 1

2
4
0110
1010
1101
0010
4
0111
1010
1101
1010

예제 출력 1

1022423354
2538351020

힌트

For the first test case, $ans[1..15] = \{1, 1, 2, 1, 2, 2, 3, 1, 1, 1, 2, 2, 2, 2, 3\}$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 4: Ce Bin and Ryyi Ji Contest 1 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /