Editorial for WC '17 Contest 3 J4 - Meme Generator


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.

Upon reading in the input, the trickiest part is determining where exactly the T and B strings should be overlaid onto the image grid, such that they end up centered as required.

Let |T| be the number of characters in T. Then, the first character of T should replace character s = \lfloor \frac{C-|T|}{2} \rfloor+1 in the second row of the image grid (1-indexed). At that point, we can iterate over each character T_i (for i = 1 \dots |T|), and if T_i isn't an underscore, we should replace character s+i-1 in the second row of the image grid with T_i.

The same process can be repeated to overlay B onto the second-last row of the image grid. Following that, we can proceed to output the entire updated image grid, one row at a time.


Comments

There are no comments at the moment.