結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
syunsuke
|
| 提出日時 | 2018-06-21 23:57:13 |
| 言語 | Python3 (3.14.2 + numpy 2.4.0 + scipy 1.16.3) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,593 bytes |
| 記録 | |
| コンパイル時間 | 267 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 111,488 KB |
| 最終ジャッジ日時 | 2024-11-25 13:45:41 |
| 合計ジャッジ時間 | 80,154 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 21 TLE * 11 |
ソースコード
HW=input()
HW=HW.rstrip().split(" ")
H=int(HW[0])
W=int(HW[1])
list1=[]
list1.append([2]*(W+2))
for i in range(H):
list2=[2]
line=input()
line=line.rstrip().split(" ")
for j in range(W):
list2.append(int(line[j]))
list2.append(2)
list1.append(list2)
list1.append([2]*(W+2))
#print(list1)
count=0
box=[]
for k in range(1,H+1):
for l in range(1,W+1):
if list1[k][l]==1:
count=count+1
list1[k][l]=3
if list1[k][l+1]==1:
box.append([k,l+1])
if list1[k][l-1]==1:
box.append([k,l-1])
if list1[k+1][l]==1:
box.append([k+1,l])
if list1[k-1][l]==1:
box.append([k-1,l])
if len(box)==0:
pass
else:
for n in range(H*W):
list1[box[0][0]][box[0][1]]=3
if list1[box[0][0]][box[0][1]+1]==1:
box.append([box[0][0],box[0][1]+1])
if list1[box[0][0]][box[0][1]-1]==1:
box.append([box[0][0],box[0][1]-1])
if list1[box[0][0]+1][box[0][1]]==1:
box.append([box[0][0]+1,box[0][1]])
if list1[box[0][0]-1][box[0][1]]==1:
box.append([box[0][0]-1,box[0][1]])
box.pop(0)
if len(box)==0:
break
else:
n+=1
else:
l+=1
#print(list1)
print(count)
syunsuke