https://ac.nowcoder.com/acm/problem/266841 n,m=map(int,input().split()) mp=[list(input()) for _ in range(n)] vis=[[False]*1005 for _ in range(1005)] l,r,u,b=m,0,0,n cnt=0 ans=0 def dfs (x,y): global l,r,u,b,cnt l=min(l,y) r=max(r,y) u=max(u,x) b=min(b,x) cnt+=1 vis[x][y]...