Editorial for TSOC '15 Contest 2 #2 - Diamonds
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Before the explanation: the problem has no tricks and no corner cases, since is guaranteed to be odd. Thus if the algorithm performs correctly, you will AC all test cases.
Now, a reasonable way to solve this problem would be to have two for loops (one for the top of the diamond, the other for the bottom). To figure out how many asterisks we have to put on line, consider how far we are in the loop. The number of asterisks can be found using the equation: and the number of spaces . This is really all you need to do to solve this 5 point problem.
Time Complexity:
Comments