Woburn Challenge 2017-18 Round 3 - Junior Division
Problem 4: Meme Generator
As part of your internship at a popular meme generation site, you've been tasked with implementing a new ASCII art feature!
You're given a grid of non-whitespace characters with R rows and C columns (5 ≤ R, C ≤ 100), representing a meme image. The user will then be able to specify two pieces of custom text to overlay onto the image, near its top and bottom edges, in order to enhance its comedic effect.
The user will first specify a non-empty string T with length no greater than C − 2. Each of its characters will be either an uppercase letter or an underscore, and it will neither start nor end with an underscore. This string should be laid on top of the image in the second row from the top, and horizontally centered. If it can't be perfectly centered (for example, if its length is odd while C is even), then it should instead be placed slightly to the left, as close to centered as possible. Underscores should be omitted, allowing the original image's characters to show through at those locations instead.
Finally, the user will specify a non-empty string B with the same constraints as T. It should similarly be laid on top of the image in the second row from the bottom, and horizontally centered.
Your task is to generate the resulting R×C image after both strings T and B have been laid on top of it, and give it back to the user, so that they can go post it on various social media platforms and obtain millions of well-deserved upvotes for their original, creative comedic content.
Input Format
The first line of input consists of two space-separated integers, R and C.
R lines follow, the i-th of which consists of C characters representing the i-th row of the image grid, for i = 1..R.
The next line consists of a single string, T.
The next line consists of a single string, B.
Output Format
Output R lines with C characters per line, the i-th of which should be the i-th row of the updated image grid.
Sample Input
17 28 ........._.............__... ........|+\.........../++|.. ........|__\______.../+++|.. ......./==========\_/++++|.. ....._/=============\++++|.. ..._/================\_++|.. ../===/#\==============\_|.. ..|==\##/====/##\========\.. .|===========\##/=========\. .|=================++++====| |====####=========++++++===| |===|####=========++++++===| |===\###___/======++++++===| |==================++++====| .|========================|. ..\=======================|. ...\=====================/.. VERY_ART WOW
Sample Output
........._.............__... ........|+VERY.ART..../++|.. ........|__\______.../+++|.. ......./==========\_/++++|.. ....._/=============\++++|.. ..._/================\_++|.. ../===/#\==============\_|.. ..|==\##/====/##\========\.. .|===========\##/=========\. .|=================++++====| |====####=========++++++===| |===|####=========++++++===| |===\###___/======++++++===| |==================++++====| .|========================|. ..\=========WOW===========|. ...\=====================/..
Sample Explanation
Much ASCII.
All Submissions
Best Solutions
Point Value: 7
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 23, 2018
Author: SourSpinach
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
such skill
very gauss
much help