BFS complext state

Revision en1, by Reslan, 2016-09-22 18:39:45

Hello everyone

I've trying to solve this problem for a long time but couldn't figure out the solution

since the problem is asking for the minimum number of moves to get to the goal square from statring square

it's solvable with BFS

but the interesting part is how can I represent my state ?

x, y : my position in the grid where x denotes the row and y denotes the column

gridMask : the number of paintings in the grid is exactly 6 , so I'm transferring them to numbers 0, 1, 2, 3, 4, 5, 6,  , at start gridMask is equal to (1«6) - 1 ( since all the painting are in the grid ) , when rolling a blank face of the cube onto a square that had painting , we exclude the corresponding bit to this painting , and move to a new state where this painting was removed from the grid .

cubeMask : as long as the cube is six sided , the state of the cube faces can be represented with a mask to tell us whether the rolled face of the cube is blank or not , model the cube faces as frontFace = 0, backFace = 1, leftFace = 2, rightFace = 3, topFace = 4, bottomFace = 5 , one can easily check whether the rolled face is blank by testing the corresponding bit if(cubeMask&(1«someFace))

till now everything is clear

in the problem statement it was mentioned that when rolling a face of the cube to a square that has no paintings and the face of the cube had painting , the painting transferred from the cube to the grid

so we move to a new state where the corresponding bit of that painting is set on in gridMask and the corresponding bit of the rolled face of the cube is set of in cubeMask

to check if some face of the cube is blank or not already done

but how can I determine for each non-blank face of the cube , the color on that face ?

thanks in advance

Tags bfs, bitmask, north america, acm icpc regional, 2012

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Reslan 2016-09-22 18:39:45 2007 Initial revision (published)