HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Search > problem:


50535 - Image Compression

Guest
• Review clarifications (1)

Section problems

• 50832 - Rock Paper Scissors Lizard ...
• 50834 - The train which leaves the f...
• 51078 - Max trade
• 51056 - Welcome Picnic
• 51055 - The competition
• 51077 - Grades Histogram
• 51057 - Number of students
• 51046 - The biggest number
• 50535 - Image Compression
• 50450 - Last Appereance of a Number
• 50457 - The Number of Winners
• 50453 - The Cubic Difference
• 50451 - Processing Cost
• 50459 - The Biggest Digit
• 50538 - Sum of kth Diagonal
• 50465 - How many students have p...
• 50378 - Sum of the given digits

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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



Для отправки решений необходимо выполнить вход.

www.contester.ru