結果
問題 | No.697 池の数はいくつか |
ユーザー | 👑 Kazun |
提出日時 | 2020-06-02 16:03:42 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,138 bytes |
コンパイル時間 | 260 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 316,876 KB |
最終ジャッジ日時 | 2024-05-04 06:59:23 |
合計ジャッジ時間 | 10,082 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
55,296 KB |
testcase_01 | AC | 39 ms
55,296 KB |
testcase_02 | AC | 39 ms
53,800 KB |
testcase_03 | AC | 38 ms
54,552 KB |
testcase_04 | AC | 38 ms
54,392 KB |
testcase_05 | AC | 39 ms
54,320 KB |
testcase_06 | AC | 39 ms
54,184 KB |
testcase_07 | AC | 40 ms
55,816 KB |
testcase_08 | AC | 40 ms
55,088 KB |
testcase_09 | AC | 46 ms
54,356 KB |
testcase_10 | AC | 42 ms
55,864 KB |
testcase_11 | AC | 39 ms
54,356 KB |
testcase_12 | AC | 40 ms
54,180 KB |
testcase_13 | AC | 39 ms
54,768 KB |
testcase_14 | AC | 39 ms
55,864 KB |
testcase_15 | AC | 39 ms
54,416 KB |
testcase_16 | AC | 40 ms
54,256 KB |
testcase_17 | AC | 42 ms
55,148 KB |
testcase_18 | AC | 41 ms
53,920 KB |
testcase_19 | AC | 39 ms
54,172 KB |
testcase_20 | AC | 40 ms
53,924 KB |
testcase_21 | AC | 39 ms
54,744 KB |
testcase_22 | AC | 38 ms
55,896 KB |
testcase_23 | AC | 39 ms
55,484 KB |
testcase_24 | MLE | - |
testcase_25 | -- | - |
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()) def f(x,y): return y*(W+2)+x def g(n): return (n%(W+2),n//(W+2)) def BFS(V,A): Q=deque([V[0]]) S={v:False for v in V} S[V[0]]=True T=[V[0]] while Q: v=Q.popleft() N=[] (x,y)=g(v) if A[y][x+1]==1 and not S[v+1]: Q.append(v+1) T.append(v+1) S[v+1]=True if A[y][x-1]==1 and not S[v-1]: Q.append(v-1) T.append(v-1) S[v-1]=True if A[y+1][x]==1 and not S[v+(W+2)]: Q.append(v+(W+2)) T.append(v+(W+2)) S[v+(W+2)]=True if A[y-1][x]==1 and not S[v-(W+2)]: Q.append(v-(W+2)) T.append(v-(W+2)) S[v-(W+2)]=True return T A=[[0]*(W+2)] for i in range(H): A.append([0]+list(map(int,input().split()))+[0]) A+=[[0]*(W+2)] V=[] for y in range(H+2): for x in range(W+2): if A[y][x]==1: V.append(f(x,y)) U=set() X=set(V) k=0 while U!=X: k+=1 U|=set(BFS(list(X-U),A)) print(k)