|
||||||||||
PuzzleTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 751 Accepted Submission(s): 266 Problem Description One day, Resty gets a very interesting puzzle. Eve said that she will make a cake for Resty if he solved this puzzle, so Resty asks you to help him to solve the puzzle as soon as possible. As the figure, the puzzle is a rectangle divided into 4 * 6 = 24 squares. Each cell has a color of white / black/ grey. There are exactly 8 cells of each color. Our purpose is to make the middle 8 cells(which are not on the edge) have the same color by minimal steps. Each step, you could choose a row or a column to shift it for 1 bit. As following: Now, given the puzzle, you should help Resty find the minimal steps he must use to solve it. Input The first line is a number T, the number of test case. Each case contains 4 lines, each line contains a 6-length string, describe a puzzle. B for black color, W for white and G for grey. Output For each test, output on line in the Format ¡°Case ID: ANS¡±, ANS should be the minimal number of steps to solve the puzzle. Sample Input
Sample Output
Author Resty Source | ||||||||||
|