F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

2-Dimensional Rubik's Cube

Time Limit: 30000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 583    Accepted Submission(s): 144


Problem Description
Alex loves Rubik's Cube. The 3-dimensional cubes are so difficult that Alex can only challenge the 2D ones, which have
six colors: W, Y, R, O, G, B.

Alex names the six faces as U(upper), D(bottom), L(left), R(right), F(front), B(back). The expanded cube will appear like
this:

Alex is able to rotate any face 90 degrees in clockwise or counter-clockwise in a second. U, D, L, R, F, B are used for rotating the
corresponding face in clockwise, while U', D', L', R', F', B' are for counter-clockwise.

Now Alex got a Cube, he wants to know the minimum number of steps required for making one state to the other.
 

Input
The input consists of multiple test cases. The first line of input contains an integer T, which is the number of
test cases.

Each test case is on 12 lines. The first 6 lines indicate the initial state, while the next 6 lines indicate the destination state,
both according to the form of the sample input.

[Technical Specification]
T is an integer, and T <= 10.
You can assume that it is always possible to complete the task.
 

Output
For each test case, print the minimal steps required on a single line.
 

Sample Input
1 G W Y G W G O Y R B O R Y B R W G B O B W O R Y B B B B O O W W R R Y Y O O W W R R Y Y G G G G
 

Sample Output
10
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:32:46, Gzip enabled