High-End Artwork
InterviewTime limit4sMemory limit512 MB
Stamps are pressed onto a paper in a given order; later presses overwrite earlier ones. Print the final grid, using '.' for untouched cells.
- Level
Easy3 of 10
- Topics
- Simulation, Array, Implementation
- Solved
- No attempts yet
Problem
Junha is a painter who builds pictures out of stamps. He prepares several stamps of different sizes and shapes, then presses them onto a sheet of paper at chosen spots, one after another.
Gangmin wants to copy that method exactly. Given which stamp is pressed and where, in order, print the finished picture.
The paper starts out blank. Pressing a stamp turns every cell the stamp covers into the character at the matching spot of the stamp. A cell that already holds an earlier stamp is covered by the later one.
Input
The first line contains the height and the width of the paper. ()
The second line contains the number of stamps . () The stamps follow in order, numbered 1 through . Each stamp starts with a line holding its height and width (), followed by lines of characters each that give the shape of the stamp. Every cell of a stamp is an English letter or a digit, so a period never appears inside a stamp.
The next line contains the number of presses . () Each of the following lines contains a stamp number and coordinates , , given in the order the presses happen. (, )
and are the coordinates of the top left cell of the area the stamp covers. The top left cell of the paper is , counts down from the top and counts right from the left. No press ever reaches outside the paper.
Output
Print the finished paper on lines. Each line holds characters, and a cell that no stamp ever touched is printed as a period (.). The order of the presses must be visible in the result.