結果
問題 | No.157 2つの空洞 |
ユーザー | 6soukiti29 |
提出日時 | 2017-09-21 08:47:26 |
言語 | Nim (2.0.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,450 bytes |
コンパイル時間 | 2,834 ms |
コンパイル使用メモリ | 68,676 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-12 15:13:16 |
合計ジャッジ時間 | 7,028 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,380 KB |
testcase_14 | AC | 185 ms
4,376 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
import sequtils,strutils var W,H : int C = newSeq[string](0) cnt : int D = [[0, 1], [1, 0], [-1, 0], [0, -1]] flag : array[21, array[21, bool]] (W, H) = stdin.readline.split.map(parseInt) for h in 1..H: C.add(stdin.readline) proc tansakuA(px, py : int)= C[py][px] = chr(cnt + ord('0')) for d in D: var (ny, nx) = (py + d[1], px + d[0]) if ny >= H or ny < 0: continue if nx >= W or nx < 0: continue if flag[ny][nx] == true or C[ny][nx] == '#': continue flag[ny][nx] = true tansakuA(nx, ny) flag[ny][nx] = false for i in 0..<H: for j in 0..<W: if C[i][j] == '.': flag[i][j] = true tansakuA(j, i) cnt += 1 cnt = 1 block tansaku: while true: for i in 0..<H: for j in 0..<W: if C[i][j] == chr(cnt + ord('0')): for d in D: var (ny, nx) = (i + d[1], j + d[0]) if ny < 0 or ny >= H: continue if nx < 0 or nx >= W: continue if C[ny][nx] == '#': C[ny][nx] = char(cnt + 1 + ord('0')) elif C[ny][nx] == '0': echo cnt - 1 break tansaku cnt += 1