#P1451. 求细胞数量

    ID: 443 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>搜索广度优先搜索,BFS深度优先搜索,DFS

求细胞数量

Description

A rectangular array consists of digits 00 to 99. Digits 11 to 99 denote cells. Two positions belong to the same cell if, moving up, down, left, or right through positions with cell digits, they are connected. Given the array, count the number of cells.

Input Format

The first line contains two integers nn and mm.

The next nn lines each contain a string of length mm consisting only of characters 0 to 9, representing the n×mn \times m matrix.

Output Format

Output a single integer, the number of cells.

4 10
0234500067
1034560500
2045600671
0000000089

4

Hint

Constraints

For 100%100\% of the testdata, 1n,m1001 \le n, m \le 100.

Translated by ChatGPT 5