HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Search > problem:


50791 - Mine field

Guest
• Discussion of problem (1)

Section problems

• 51046 - The biggest number
• 50453 - The Cubic Difference
• 50451 - Processing Cost
• 50538 - Sum of kth Diagonal
• 50535 - Image Compression
• 50470 - Close Pairs - Revised
• 50459 - The Biggest Digit
• 50784 - Top Growing Company
• 50791 - Mine field
• 50867 - Average of the Best Grades
• 50460 - Median of 3 Numbers
• 50566 - Grade Point Average (GPA)
• 50573 - Count and Sum
• 50575 - Number of Prime numbers
• 50576 - Number of Perfect numbers
• 50588 - Processing the list of numbers
• 50547 - Close Pair

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