#K77597. Remove Gray Pixels
Remove Gray Pixels
Remove Gray Pixels
You are given an image represented as a 2D array of pixels. Each pixel is described by three integers representing the red, green, and blue (RGB) components. A pixel is considered gray if its red, green, and blue components are all equal, i.e., \(R = G = B\).
Your task is to process the image by removing all gray pixels from every row. The modified image should retain the order of the remaining (non-gray) pixels in each row.
Note: If a row contains only gray pixels or becomes empty after processing, output an empty line for that row.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains an integer \(n\) representing the number of rows in the image.
- For each row, the first integer \(k\) indicates the number of pixels in that row, followed by \(3 \times k\) integers. Each set of three consecutive integers represents the R, G, and B values of a pixel.
For example, an image with 3 rows may be provided as:
3 3 30 30 30 0 0 255 40 40 40 3 255 255 255 128 128 128 255 0 0 3 0 0 0 10 10 10 100 200 100
outputFormat
The output should be printed to standard output (stdout). For each row in the processed image, print a line containing the non-gray pixels. For each non-gray pixel, output its three components separated by a space. If a row contains no non-gray pixels, output an empty line.
For example, the expected output for the sample input above is:
0 0 255 255 0 0 100 200 100## sample
3
3 30 30 30 0 0 255 40 40 40
3 255 255 255 128 128 128 255 0 0
3 0 0 0 10 10 10 100 200 100
0 0 255
255 0 0
100 200 100
</p>