結果
問題 | No.157 2つの空洞 |
ユーザー | yuyyuyu |
提出日時 | 2015-08-04 08:18:09 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 626 bytes |
コンパイル時間 | 509 ms |
コンパイル使用メモリ | 77,752 KB |
実行使用メモリ | 79,144 KB |
最終ジャッジ日時 | 2023-09-25 00:59:36 |
合計ジャッジ時間 | 2,974 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
75,740 KB |
testcase_01 | AC | 78 ms
76,204 KB |
testcase_02 | AC | 77 ms
76,944 KB |
testcase_03 | AC | 80 ms
78,136 KB |
testcase_04 | AC | 81 ms
78,700 KB |
testcase_05 | AC | 82 ms
78,508 KB |
testcase_06 | AC | 86 ms
78,540 KB |
testcase_07 | AC | 78 ms
77,004 KB |
testcase_08 | AC | 81 ms
78,448 KB |
testcase_09 | AC | 83 ms
78,304 KB |
testcase_10 | AC | 81 ms
78,556 KB |
testcase_11 | AC | 85 ms
78,808 KB |
testcase_12 | AC | 84 ms
79,144 KB |
testcase_13 | AC | 88 ms
78,816 KB |
testcase_14 | AC | 95 ms
78,904 KB |
testcase_15 | AC | 90 ms
78,880 KB |
testcase_16 | AC | 90 ms
78,592 KB |
testcase_17 | AC | 91 ms
78,840 KB |
testcase_18 | AC | 88 ms
78,940 KB |
testcase_19 | AC | 86 ms
78,592 KB |
ソースコード
dxy=zip([1,0,-1,0],[0,1,0,-1]) def rec(x,y,cnt): C[y][x]=str(cnt) for dx,dy in dxy: nx,ny=x+dx,y+dy if 0<=nx<W and 0<=ny<H and C[ny][nx]=='.': rec(nx,ny,cnt) W,H=map(int,raw_input().split()) C=[list(raw_input()) for i in xrange(H)] cnt=0 for y in xrange(H): for x in xrange(W): if C[y][x]=='.': rec(x,y,cnt) cnt+=1 ans=100000 for y1 in xrange(H): for x1 in xrange(W): for y2 in xrange(H): for x2 in xrange(W): if C[y1][x1]=='0' and C[y2][x2]=='1': ans=min(ans,abs(x1-x2)+abs(y1-y2)) print ans-1