Rhonda
Time limit1sMemory limit1024 MB
Given several 10x10 layers, sum the layers named in each data set cell by cell and print each resulting 10x10 grid.
- Level
Easy2 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Problem
Rhonda prints processor chips. Each chip is made from fabricated components inscribed onto thin layers. She stacks two or more layers together to create a final chip made up of multiple layers.
Rhonda has several unique layers. She can combine them in various numbers to make a variety of chips. Each layer is a 10x10 grid of integers, and each cell holds an integer from 0 to 9. The final chip is also a 10x10 grid. Each cell is the sum of the values in that same position across the layers used to make the chip.
Layers are numbered in the order given, starting at zero. For example, combining only the first and second layers gives the data set 0 1.
The value of each cell in an individual layer is in the range 0 to 9. The value of each cell in a final chip is in the range 0 to 99. All original layers are unique.
Input
The first line contains an integer i, the number of unique layers. Next come i grids of 10x10 integers, each followed by a newline. The next line contains a positive integer n, the number of data sets. Each data set is one line of integers separated by spaces. These integers are the numbers of the layers used to make a chip.
Output
Print the summed chip for each data set as a 10x10 grid. Each cell is shown as two digits, with one space between cells.