|
Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Image Compression
You want to write an image compression program
with the following algorithm. You count the
number of occurrences of a number and write the
number of occurrences followed by the number
itself. e.g. If you have
77 77 243
243 243 243
57 57 57 77 77
you can compress it to:
2 77 4 243 3 57 2 77
(There are two consecutive 77s, then there are four 243s, etc.)
Question:
Write a program that reads an image and prints
the compressed version of it.
Input specification
First, you will be given two integers (n,m)
where n and m are between 0 and 2000.
Then, in the following n lines, you will
be given m integers which are between 0 and 255
Output specification
Show the compressed version.
Sample Input I
4 5
84 84 84 126 126
126 32 32 126 126
32 32 32 126 126
126 126 32 32 32
|
Sample Output I
3 84 3 126 2 32 2 126 3 32 4 126 3 32
|
Для отправки решений необходимо выполнить вход.
|