Pebbles

Original source: ICPC Pacific Northwest 2007

  1. Read the problem and summarise the task requirements.
  1. Our goal is to assign pebbles to certain values. In what order should we approach this?

  2. Propose a very simple subproblem, so that if you knew the answer to all subproblems, then you could deduce the overall answer. Start with as few parameters as possible.

  3. When you are at a square, what information would let you know whether it is legal to place a pebble here?
  4. What further information do you need to know in order to maintain it? That should also be part of your subproblem specification.
  5. What data structure can be used to collect all these additional parameters?

  6. Form a recurrence between your subproblems.

  7. Analyse the time complexity of your algorithm, and estimate the running time.
  8. Implement this algorithm in code.

Unfortunately this problem isn’t available for judging.