ENIGMA-0x02 (2024) - A1 (The good tablecloth))

View as PDF

Submit solution

Points: 100 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
Blockly, C, C++, Java, Pascal, Python

The Good Tablecloth

Whenever guests come over, Mom always brings out the good dishes and the good tablecloth. But tomorrow, she has an unexpected visit, and the tablecloth is in the laundry! So, she asks Toto for help to color an old tablecloth, hoping to save the day.

She is very strict about what makes a good tablecloth:

  1. It has only 2 colors: red and green.
  2. It has horizontal and vertical lines dividing it into rectangular sections (parts).
  3. To make the lines visible to the eye, the parts that share an edge must be colored differently.

She hands the tablecloth to Toto and specifies the lines she wants to see. Totos needs to color it appropriately.

Input Data (STDIN)

The first line of input provides 2 positive integer numbers:

  • N, the length, and
  • M, the width of the tablecloth, separated by a space (' ').

The next line starts with a positive integer h, the number of horizontal lines, followed by a new line containing h positive integers h_i, separated by spaces (' '), where h_i is the distance of the i-th line from the top edge of the tablecloth.

This is followed by a new line that starts with a positive integer v, the number of vertical lines, followed by a new line containing v positive integers v_i, separated by spaces (' '), where v_i is the distance of the i-th line from the leftmost edge of the tablecloth.

It holds that K = h + v.

Output Data (STDOUT)

The program will output N lines, each containing M characters, which are either G or R, such that the resulting output forms the tablecloth after Toto's intervention.

Note: If there are more than 1 possible answers, print any you prefer.

Examples

1st
Input (STDIN)

4 5
1 2
2 1 4

Output (STDOUT)

GRRRG  
GRRRG  
RGGGR  
RGGGR


2nd
Input (STDIN)

4 5
3 1 2 3
4 1 2 3 4

Output (STDOUT)

GRGRG  
RGRGR  
GRGRG  
RGRGR


Subtasks
  • 70\% of the points: 1 \le N, M, K \le 500
  • 100\% of the points: 1 \le N, M \le 5,000,\; 1 \le K \le 10^6

    The same line-column may appear multiple times: if it appears an odd number of times, it should appear on the tablecloth; otherwise, it should not.

Comments

There are no comments at the moment.