- 313
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
You are going to write a simple program to decode some arrays of data into a black-and-write graphic.The graphic is composed of n lines of black and white pixels. We use
For example, here is one line of graphic
....OOO.
We shall encode it into an array
because it starts with
We assume most lines shall start with white.
When there is a line starting with black, we add
For example
will be encoded into
You must output
In this puzzle, you will be given n lines of encoded data.
You are going to decode it into a graphic.
Input
First line : Number n of rows in the graphic (integer)
n next lines : An array of integers representing the encoded nth line of the graphic
n next lines : An array of integers representing the encoded nth line of the graphic
Output
If the grid is not a rectangle : INVALID
Otherwise : n lines of the grid (equal length), each pixel represented by. /O , no spaces
Otherwise : n lines of the grid (equal length), each pixel represented by
Constraints
n < 200
Example
Input
4 1 3 2 1 1 3 2 1 1 3 2 1 1 3 2 1
Output
.OOO..O .OOO..O .OOO..O .OOO..O
A higher resolution is required to access the IDE