HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Search > problem:


50791 - Mine field

Guest
• Discussion of problem (1)

Section problems

• 50459 - The Biggest Digit
• 50538 - Sum of kth Diagonal
• 50465 - How many students have p...
• 50378 - Sum of the given digits
• 50470 - Close Pairs - Revised
• 50784 - Top Growing Company
• 50458 - Weekly Report
• 50478 - Letter Grades
• 50791 - Mine field
• 50867 - Average of the Best Grades
• 50782 - Max of N integers
• 50460 - Median of 3 Numbers
• 50552 - Casual shoes
• 50558 - Biggest Barn
• 50562 - List of students
• 50566 - Grade Point Average (GPA)
• 50570 - Prime numbers in the seg...

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