Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Announcement
Problems
Submit Problem
Status (Online)
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest

Little guys' game

Time Limit:1000MS  Memory Limit:65536K
Total Submit:324 Accepted:76

Description

Here is game played by little guys. There is a 4 * 4 square, and the square is filled with the characters 'A', 'B', 'C' and 'D'. Each kind of character appears exactly 4 times. You can arbitrarily swap two adjacent characters (horizontal or vertical). At the beginning of the game you should choose a character (from 'A', 'B', 'C' and 'D') as you target character, when any 2 * 2 sub-square contains the same character as the character you have chosen before, you win the game.

These little guys want to use minimal times of swap to win the game. Now they turn to you. Can you help them?

Input

There are multiple test cases. Each contains a 4 * 4 square as the initial situation. Notice that the square only contains 'A', 'B', 'C' and 'D', and each kind of characters will appear exactly 4 times.

Output

You should output the minimal swap times to win the game, and you should also output how many kinds of strategies you can achieve the minimal swap times.

You should pay attention that if two strategies swap the characters in the same order but with the different target characters, these two strategies are still considered as different.

Sample Input

AABB
ABAB
CDCD
CCDD

ACAB
CBBD
ADAD
DCBC

Sample Output

1 4
4 96

Source

POJ Monthly--2005.07.31, Huang Ninghai

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Copyright Reserved 2003-2005 Ying Fuchen,Xu Pengcheng
Any problem, Please Contact Administrator