Given n anchor points and a four-limb climbing model with pairwise distance and height limits, find the fewest moves to touch location n.
Medium6BFSGraphSimulationGeometryNo attempts yetTime limit2sMemory limit512 MBA climbing wall, natural or man made, has small holes and protrusions where you can put your fingers or your toes. Reaching a target spot takes planning as much as strength, because before each move you have to know that some limb can go somewhere useful for the step after it.
This problem models that planning as follows. You are given n locations on a two dimensional wall. One location takes one hand or one foot. In one move you put exactly one limb on another location, and these rules hold at every moment:
You start with your left foot on location 1, your right foot on location 2, your left hand on location 3, and your right hand on location 4. The starting position always obeys the rules. You have climbed the wall once any limb is on location n. Find the smallest number of moves that puts a limb on location n.
The first line contains an integer K with K≥1, the number of data sets. K data sets follow, each in this form.
The first line of a data set contains one integer n with 4≤n≤30, the number of locations. The next line contains 2n real numbers x1, y1, x2, y2, ..., xn, yn, where (xi,yi) is the position of location i.
For each data set, first print "Data Set x:" on a line of its own, where x is the number of the data set counted from 1. On the next line print the minimum number of moves until a limb first touches location n. If no sequence of moves puts a limb on location n, print Impossible on that line instead. Print a blank line after each data set.