JOIN

 Problem Statement

Problem Statement for ClassicTowers

### Problem Statement

This problem is related to the classic "Tower of Hanoi" puzzle. The puzzle consists of three rods and n disks. The rods are labeled A, B, and C. The disks all have different sizes, and they are numbered 0 through n-1 from smallest to largest.

In a valid configuration, each disk is placed onto one of the three rods and on each rod the disks are ordered by size: smallest to largest from top to bottom. In order to specify a configuration we just need to specify the rod for each disk, as the order of disks on each rod is uniquely determined by their sizes.

A valid move is a move in which we take the topmost disk from one of the rods and place it onto the top of the disks on another rod in a way that produces a valid configuration. That is, given a valid configuration, a move is only valid if a) you are moving the topmost disk from one rod onto another rod that is currently empty, or b) the disk you are moving is smaller than the current topmost disk on the destination rod.

A solution is a sequence of valid moves that produces a configuration in which all n disks are in a single stack on an arbitrary rod.

You are given a int[] count with three elements and an int k. Construct any valid configuration with the following properties:

• There are exactly count[0] disks on rod A.
• There are exactly count[1] disks on rod B.
• There are exactly count[2] disks on rod C.
• The shortest solution for this configuration consists of exactly k moves.

If there is no such configuration, return an empty String. Otherwise, return a String with n = sum(count) characters. For each valid i, character i of the return value should be the name of the rod where disk i is placed. If there are multiple possible solutions, you may return any of them.

### Definition

 Class: ClassicTowers Method: findTowers Parameters: long, int[] Returns: String Method signature: String findTowers(long k, int[] count) (be sure your method is public)

### Constraints

-k will be between 0 and 2^50 - 1, inclusive.
-count will have exactly 3 elements.
-Each element of count will be between 0 and 50.
-The sum of elements in count will be between 1 and 50, inclusive.
-Elements in count will be in a non-decreasing order.

### Examples

0)

 `4` ```{1,1,2} ```
`Returns: "CCAB"`
 The returned value represents disk 0 and 1 on rod C, disk 2 on rod A, and disk 3 on rod B. Here, we can put all disks onto rod B as follows: Move disk 2 onto rod B. Move disk 0 onto rod A. Move disk 1 onto rod B. Move disk 0 onto rod B.
1)

 `0` ```{0, 0, 50} ```
`Returns: "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"`
 The return value represents all disks on rod C.
2)

 `0` `{10,20,20}`
`Returns: ""`
 This is impossible. A configuration with some disks on each rod clearly doesn't have any solution with 0 moves.
3)

 `123456123456123` ```{10,10,30} ```
`Returns: "CCACCCACCABACCABBACCCBBCCBCCCBACCCCABBACCCCCACBCCC"`
4)

 `314159265358979` `{15,16,17}`
`Returns: ""`

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
Single Round Match 715 Round 1 - Division I, Level Two