<PREV Problem:
NEXT>
Solved by 150 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Chess Cube

Time limit = 5 second(s)

Cube is on one of square of chessboard. There are positive integers on cube sides. You should roll the cube to the desination square and get minimal penalty. Each move penalty is increased be the number that is on the down-side of the cube.

Input The initial and the destination square of the cube. Then six numbers follow: numbers on the south, north, up, right, down and left sides.

Output Your program should output minimal penalty.

Input#1
a1 b2 1 1 1 1 1 1
Output#1
3 
Input#2
e2 e3 0 8 1 2 1 1
Output#2
5

Author:
III St-Peterburg school team contest, 9 December 1995. Played at MIPT contest 3 October 2004.

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 170ms

SW soft NIX
ID = 54.158.248.167