Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
30 kB
1
Indexable
Never
Painting


The design team at SAMSUNG Electronics considers an innovative design for a new product.

The left figure is the basic diagram and the design team tries to distinguish each area marked by letter of the alphabet with four colors.

When proceeding with this, the design team pursues perfection by researching the combinations of all colors and chooses one of them.

However, they have trouble because they do not know the total number of cases of the color combinations.

Due to this difficulty, you convert the basic diagram on the left to the graph in the center and then you solve the problem by converting it to the adjacency matrix on the right.

The number of cases is 264.

 

What is the method used to solve this?  (Time Limit : 2 seconds)

 

 


[Input]

 

The adjacency matrix about a basic diagram is entered.

On the first line, the number of the test cases (1<=T <= 10) is given.

On the first line of each test case, the size of the matrix n (1<=n <= 30, n is the positive number).

From the second line, the values of matrix are entered by being distinguished as one blank or other.

 


[Output]

 

For each test case, you should print "Case #T" in the first line where T means the case number.
In the second line, print out the total number of cases to paint and distinguish them with four colors for each area.

 


[Sample Input ]

3

4

0 0 0 1

0 0 0 1

0 0 0 1

1 1 1 0

5

0 1 1 1 0

1 0 0 1 1

1 0 0 1 0

1 1 1 0 1

0 1 0 1 0

7

0 1 0 0 1 0 1

1 0 1 0 1 0 0

0 1 0 1 1 0 0

0 0 1 0 1 1 0

1 1 1 1 0 1 1

0 0 0 1 1 0 1

1 0 0 0 1 1 0

 


[Sample Output]

Case #1
108

Case #2
96

Case #3
264

50
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 0 1 1 0 0 1 1 0 0 1 1 
0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 
0 1 0 0 1 1 0 1 0 1 0 1 0 1 1 
0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 
0 1 0 1 1 0 0 1 0 0 1 1 1 0 0 
0 1 1 0 1 0 0 0 0 1 1 1 0 0 0 
0 0 1 1 0 1 0 0 0 1 0 0 0 1 1 
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 
0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 
0 1 0 0 1 1 1 0 1 1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 0 0 0 
0 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 0 0 
16
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 0 0 1 0 0 0 0 1 1 0 1 1 1 
0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 
0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 0 
0 0 1 1 0 1 0 0 1 0 0 1 0 0 0 0 
0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 0 
0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 
0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 0 1 1 0 0 0 1 0 1 0 1 0 1 
0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 0 
0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 0 
0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 
0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 0 
0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 1 
0 1 1 1 0 0 1 0 0 0 0 0 0 1 0 1 
0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0

#include <iostream>
using namespace std;

int n;
int arr[31][31];
int dd[31];
int dem;

bool check(int i){
	for(int j=0; j<n; j++){
		if(arr[i][j] == 1 && dd[i] == dd[j])
			return false;
	}
	return true;
}

void backTrack(int i){

	if(i == n){
		dem++;
		return;
	}

	for(int j=1; j<=4; j++){
		dd[i] = j;
		if(check(i))
			backTrack(i+1);
		dd[i] = 0;
	}

}

int main(){

	//freopen("vao.txt", "r", stdin);

	int t;
	cin >> t;
	for(int tc=1; tc<=t; tc++){

		cin >> n;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				cin >> arr[i][j];
			}
		}

		dem = 0;

		for(int i=0; i<n; i++){
			dd[i] = 0;
		}

		backTrack(0);

		cout << "Case #" << tc << endl;
		cout << dem << endl;
	}
	return 0;
}