2012 Canadian Computing Competition: Senior Division: Sponsor
2012 Canadian Computing Competition: Senior Division: Sponsor
Sponsor:
Ontario Central and West Quebec and Atlantic 12. If you nish in the top 20 competitors on this competition, you will be invited to participate in CCC Stage 2, held at the University of Waterloo in May 2012. We will select the Canadian International Olympiad in Informatics (IOI) team from among the top contestants at Stage 2. You should note that IOI 2012 will be held in Italy. Note that you will need to know C, C++ or Pascal if you are invited to Stage 2. But rst, do well on this contest! 13. Check the CCC website at the end of March to see how you did on this contest, and to see who the prize winners are. The CCC website is: www.cemc.uwaterloo.ca/ccc
The value of a pair AR is A times the base value of R. Normally, you add up the values of the pairs to get the overall value. However, wherever there are consecutive symbols ARA R with R having a strictly bigger base value than R, the value of pair AR must be subtracted from the total, instead of being added. For example, the number 3M1D2C has the value 3 1000 + 1 500 + 2 100 = 3700 and 3X2I4X has the value 3 10 2 1 + 4 10 = 68. Write a program that computes the values of aromatic numbers. Input Specication The input is a valid aromatic number consisting of between 2 and 20 symbols. Output Specication The output is the decimal value of the given aromatic number. Sample Input 1 3M1D2C Output for Sample Input 1 3700 Sample Input 2 2I3I2X9V1X Output for Sample Input 2 -16 5
For some starting congurations, it is not always possible to obtain the goal of strictly increasing order.
Input Specication The input will contain some number of test cases. A test case consists of two lines. The rst line contains a positive integer n (n < 8), which is the number of coins. We assume that the coins are labeled 1, 2, 3, . . . n. The second line contains a list of numbers 1 to n in an arbitrary order, which represents the initial coin conguration. For the above example, the input test case would be: 3 3 2 1 The end of test cases is indicated by 0 on a line by itself. Output Specication For each test case, output one line, which will either contain the minimal number of moves in which Jo can achieve the goal coin line-up, or, if it is not possible to achieve the goal coin line-up, IMPOSSIBLE. Sample Input 3 3 2 1 2 2 1 0 Output for Sample Input 20 IMPOSSIBLE
10