if position not visited add to queue and mark visited
q . push ( { s + d1 , stp + 1 } ) ; visited . insert ( s + d1 ) ; } if ( visited . find ( s + d2 ) == visited . end ( ) ) { q . push ( { s + d2 , stp + 1 } ) ; visited . insert ( s + d2 ) ; } if ( visited . find ( s - d1 ) == visited . end ( ) ) { q . push ( { s - d1 , stp + 1 } ) ; visited . insert ( s - d1 ) ; } if ( visited . find ( s - d2 ) == visited . end ( ) ) { q . push ( { s - d2 , stp + 1 } ) ; visited . insert ( s - d2 ) ; } } }