HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50791 - Mine field

Guest
• Discussion of problem (1)

Volume problems

• Word Puzzle
• 50740 - Service Time - 1
• 50928 - War Of Battleships
• 50930 - Tom and Jerry
• 50925 - Optimizing Elevator Usage
• 50988 - Laplacian Filter
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II
• 50791 - Mine field
• 50912 - Trip to Librazhd
• Trip to Librazhd
• 50914 - Buy 3, Pay 2
• 50555 - Frequency of Letters
• 50558 - Biggest Barn
• 50563 - Long Modulus
• 50565 - Binary numbers
• 50567 - Input Data Normalization

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 Rovshan Zeynalov.

Mine field

Enemies put mines to the field which is the entrance of occupied area. But spies sent some useful information about minefield. Now your army knows that enemies marked every mine. For easily find the path, enemies planted flowers to all sides of mines and one flower on the mine. Colors of flowers on all mines are same (1). Colors of flowers around one mine are same too (different from flower on the mine). However, color of flowers around one mine can be different than the color of flowers around another. For example, color of flowers on all mines is white, color of flowers around mine with coordinates [3][6] is green, but color of flowers around mine - [6][5] is blue.

Private Tofig must find coordinates of all mines and number of them. Help him. But be careful. Sneaky enemy planted colorful flowers all around. You must act on the plan.

Input specification
First line contains two numbers N and M (1 ≤ N, M ≤ 100) – sizes of matrix (minefield). Next N lines contains minefield. Each line contains M numbers from 0 to 5 (colors of flowers) with no spaces.

Output specification
First show a single integer on a line – number of mines. Then show the coordinates of mines on the following lines.

Sample Input I
8 13
1111011112221
5111000112121
1111010112221
1311000112131
1114441112221
1114141115550
1114441115351
1141111115553
Sample Input II
4 7
2221101
2101000
2221010
1101000
Sample Output I
3
2 11
3 6
6 5
Sample Output II
1
3 6


Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru