HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC-2014-15 Questions > problem:


4th-3. 50535 - Image Compression

IMPC-2014-15 Questions

Start: Nov.22.2014 at 03:00:00 PM
Finish: Nov.22.2014 at 08:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 2nd-6. 50486 - Problems and Progr...
• 3rd-2. 50405 - Accounts Receivable
• 3rd-3. 50474 - Sum of Two Primes
• 3rd-4. 50406 - Draw Pattern 178
• 3rd-5. 50415 - The Scientist
• 3rd-6. 50695 - Longest link between...
• 4th-1. 50491 - Brokers
• 4th-2. 50524 - Elevator
• 4th-3. 50535 - Image Compression
• 4th-6. 50536 - Epoka Furgon Shpk
• Ind_01-10. 50752 - Student Groups
• Ind_01-20. 50416 - Placing Domino...
• Ind_01-30. 50764 - Fast Typing Co...
• Ind_01-50. 50718 - Elevator
• Ind_02-10. 50497 - Falling Bricks - ...
• Ind_02-20. 50745 - Bitonic Sequence
• Ind_02-30. 50657 - Permutations an...

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