0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

メモ:俺なりのLakeCounting

Posted at

記事の見てくれとか何も気にせず他の人の書いたコードをもとにして自分なりに書いたのをここに保存。

a = list(map(int,input().split()))
n = a[0]
m = a[1]
#print("n=",n,"m=",m)
field=[]
for i in range(n):
field.append(list(input()))
def dfs(x,y):
#print("x=",x,"y=",y)
field[x][y] = '.'
for dx in [-1,0,1]:
for dy in [-1,0,1]:
nx = x + dx
ny = y + dy
#print("nx=",nx,"ny=",ny)
if(0<=nx and nx<n and 0<=ny and ny<m and field[nx][ny] == 'W'):
dfs(nx,ny)
res = 0
for j in range(n):
for k in range(m):
print("j=",j,"k=",k,"field[",j,"][",k,"]=",field[j][k])
if(field[j][k]=='W'):
#print("so dfs starts!!")
dfs(j,k)
res +=1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?