Submit | All submissions | Best solutions | Back to list |
GCPC11D - Magic Star |
A magic star consists of all the numbers from 1 to 12 arranged in the shape of a hexagram:
The magic comes from the fact that in each line of 4 numbers, the sum of the numbers is 26. In the example given above, the six lines consist of the following numbers:
- 1 + 4 + 10 + 11
- 11 + 5 + 3 + 7
- 7 + 6 + 12 + 1
- 2 + 10 + 5 + 9
- 9 + 3 + 6 + 8
- 8 + 12 + 4 + 2
There are several possible ways to arrange the numbers to get a magic star. Given a partially labelled star, your task is to extend the solution such that a magic star is formed.
Input
The input consists of a visualization of the star; the unlabelled fields of the star will be represented by an 'x' character, and labelled fields will contain a letter between 'A' and 'L', where the i-th letter in the alphabet represents number i. The character '.' is used to align the fields of the star in the shape of a hexagram. You may assume that each input will use the same alignment of the fields as the one in the sample input.
Output
Print the lexicographically smallest extension of the given partial solution which is a magic star (lexicographically smallest means that the concatenation of the rows should result in a string which is lexicographically smaller than other potential solutions). You may assume that there is always a solution for the given input.
Example
Input: ....x.... .A.I.D.x. ..x...x.. .x.x.x.x. ....x.... Output: ....F.... .A.I.D.L. ..H...E.. .C.J.B.K. ....G....
Added by: | Adrian Kuegel |
Date: | 2011-07-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | German Collegiate Programming Contest 2011 (Author: Adrian Kuegel) |
hide comments
2019-05-03 03:36:26
@ Adrian Kuegel i have test my program in my computer several times .and the result is ac. but when i submit my program in the web site ,the result is wrong .can you pass me the test case . my email is 2717852461@qq.com thank! |
|
2011-10-23 18:51:32 A. Muh. Primabudi
@Adrian : at least got AC... thanks for the answer Last edit: 2011-10-23 18:54:12 |
|
2011-10-19 08:34:24 Adrian Kuegel
The output is: ....B.... .A.I.F.J. ..L...G.. .C.H.D.K. ....E.... |
|
2011-10-18 15:31:12 A. Muh. Primabudi
can i ask some test case? what is the output for ....x.... .A.I.x.x. ..x...x.. .x.x.x.x. ....x.... |
|
2011-08-10 13:44:40 Adrian Kuegel
It is just one test case (but your program will be executed several times, using different test cases). |
|
2011-08-08 21:45:43 biQar
the "number of test cases" is not mentioned here ... |