CCHECKER - Chinese Checkers

no tags 

Description

Chinese checkers is a multiplayer game played on hexagram-shaped board with the objective of moving your pieces to the opposite corner before your opponents do the same.
Each turn, a piece move in one of two ways:
  • Move to an adjacent unoccupied cell.
  • Jump over an adjacent occupied cell, to an unoccupied cell immediately opposite the occupied one. Consecutive jumps in a single turn are allowed.
The full board is a hexagram (six-pointed star), but we will narrow our focus to the center area, and two opposite corners. There are 81 cells in that region:
Given a starting position, you will get a piece as close to cell 81 as possible in a single turn. In this context, the distance from the goal is considered to be the number of moves it would take to reach it, if there were no occupied cells. For example, cells 54, 62, 70, and 78 are all 3 away from the goal.

Input

There are two lines of input. The first line is a space separated list of occupied cells.
The second line will be a space separated list of origin cells.

Output

For each origin cell, print a line consisting of the closest cell to 81 that can be reached from the origin cell in one turn. There will always be a possible move, and you cannot stay in the same place. If there is a tie in distance, choose the largest number.

Examples

Example 1 is representative of the illustration above. Starting from 1 (in blue), you can navigate to 81 by way of 3, 21, 39, 41, 43, 45, 63, 81. Starting with 7, the furthest you can get is 25, by jumping over 16.
Input Input
2 12 16 24 30 40 42 44 54 72
1 7 17 53 11 41
2 12 22 32 42 52 60 70 81
1 11 25 72 80
Output Output
81
25
51
62
13
81
79
71
34
80
72
				

hide comments
Simes: 2023-05-01 17:31:48

Loved it! Should be in classical

nadstratosfer: 2018-06-02 21:51:11

I lose faith in EB finding a problem like this in tutorial section. Deceivingly simple but a lot of pain to get right and a lot of joy to finally get the green bar. Certainly not a 10min job I had expected it to be.

Please, Francky, Blue Mary, Min25, consider this one for move to classical.

=(Francky)=> EB can't move problems. There are maybe some reasons for this problem to be here. Maybe a quite identical already exists in classical. Or ??? Psetter may answer about that in few days. Please be patient, and then consider email to contact@spoj.com. Regards.

Last edit: 2018-06-03 17:24:09

Added by:BYU Admin
Date:2015-11-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA