結果
問題 | No.697 池の数はいくつか |
ユーザー | lllllll88938494 |
提出日時 | 2022-09-22 15:59:49 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 646 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 87,036 KB |
実行使用メモリ | 439,988 KB |
最終ジャッジ日時 | 2023-08-23 20:34:45 |
合計ジャッジ時間 | 19,977 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 97 ms
71,756 KB |
testcase_01 | AC | 98 ms
71,420 KB |
testcase_02 | AC | 97 ms
71,576 KB |
testcase_03 | AC | 96 ms
71,716 KB |
testcase_04 | AC | 99 ms
71,748 KB |
testcase_05 | AC | 98 ms
71,756 KB |
testcase_06 | AC | 97 ms
71,768 KB |
testcase_07 | AC | 96 ms
71,632 KB |
testcase_08 | AC | 95 ms
71,520 KB |
testcase_09 | AC | 96 ms
71,752 KB |
testcase_10 | AC | 96 ms
71,752 KB |
testcase_11 | AC | 97 ms
71,684 KB |
testcase_12 | AC | 96 ms
71,616 KB |
testcase_13 | AC | 97 ms
71,336 KB |
testcase_14 | AC | 97 ms
71,480 KB |
testcase_15 | AC | 97 ms
71,460 KB |
testcase_16 | AC | 97 ms
71,584 KB |
testcase_17 | AC | 98 ms
71,588 KB |
testcase_18 | AC | 99 ms
71,728 KB |
testcase_19 | AC | 98 ms
71,252 KB |
testcase_20 | AC | 98 ms
71,644 KB |
testcase_21 | AC | 98 ms
71,660 KB |
testcase_22 | AC | 97 ms
71,596 KB |
testcase_23 | AC | 99 ms
71,588 KB |
testcase_24 | AC | 5,423 ms
280,548 KB |
testcase_25 | MLE | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
ソースコード
from collections import deque h,w=map(int,input().split()) grid=[list(map(int,input().split())) for i in range(h)] f=[[0]*w for i in range(h)] cnt = 1 l=[1,0,-1,0] r=[0,1,0,-1] def bfs(x,y): d=deque() d.append((x,y)) while d: x,y=d.popleft() f[x][y] = cnt for i in range(4): if 0 <= x + l[i] < h and 0 <= y + r[i] < w: if grid[x+l[i]][y+r[i]] == 1 and f[x+l[i]][y+r[i]] == 0: d.append((x+l[i],y+r[i])) for i in range(h): for j in range(w): if grid[i][j] == 1 and f[i][j] ==0: bfs(i,j) cnt += 1 print(cnt-1)