#C6018. Determine the Last Painted Color
Determine the Last Painted Color
Determine the Last Painted Color
You are given a 10×10 grid where each cell is either R
, G
, or .
representing a red paint, a green paint, or no paint at all. Two colors have been applied on the grid in separate stripes and the order of painting is deduced from their positions.
Let \(r\) be the 0-indexed row number of the last row that contains at least one R
, and let \(c\) be the maximum column index (0-indexed) such that some row has a G
in that column. If \(r > c\), then the last painted color is red (output R
); otherwise, it is green (output G
).
Each test case provides exactly 10 lines with 10 characters per line. Your task is to decide which color was painted last for every test case.
inputFormat
The input begins with an integer \(T\) indicating the number of test cases. Each test case consists of exactly 10 lines, each containing exactly 10 characters. Each character is either R
, G
, or .
.
For example, a test case might look like:
.......... .G........ .G........ RRRRRRRRRR .......... .G........ .G........ .G........ .G........ .G........
outputFormat
For each test case, output a single line containing either R
or G
— the color that was painted last according to the criteria described above.
1
..........
.G........
.G........
RRRRRRRRRR
..........
.G........
.G........
.G........
.G........
.G........
R
</p>