結果
問題 | No.697 池の数はいくつか |
ユーザー | Pump0129 |
提出日時 | 2018-09-18 18:07:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,549 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 10,948 KB |
実行使用メモリ | 89,648 KB |
最終ジャッジ日時 | 2023-08-16 22:51:26 |
合計ジャッジ時間 | 14,777 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,228 KB |
testcase_01 | AC | 16 ms
8,304 KB |
testcase_02 | AC | 17 ms
8,280 KB |
testcase_03 | AC | 16 ms
8,324 KB |
testcase_04 | AC | 16 ms
8,308 KB |
testcase_05 | AC | 16 ms
8,280 KB |
testcase_06 | AC | 17 ms
8,164 KB |
testcase_07 | AC | 16 ms
8,188 KB |
testcase_08 | AC | 16 ms
8,312 KB |
testcase_09 | AC | 16 ms
7,924 KB |
testcase_10 | AC | 16 ms
8,320 KB |
testcase_11 | AC | 17 ms
8,328 KB |
testcase_12 | AC | 16 ms
8,300 KB |
testcase_13 | AC | 16 ms
8,228 KB |
testcase_14 | AC | 16 ms
8,232 KB |
testcase_15 | AC | 16 ms
8,180 KB |
testcase_16 | AC | 16 ms
8,328 KB |
testcase_17 | AC | 16 ms
8,208 KB |
testcase_18 | AC | 16 ms
8,280 KB |
testcase_19 | AC | 16 ms
8,180 KB |
testcase_20 | AC | 16 ms
8,192 KB |
testcase_21 | AC | 16 ms
8,224 KB |
testcase_22 | AC | 16 ms
7,968 KB |
testcase_23 | AC | 16 ms
8,308 KB |
testcase_24 | AC | 955 ms
17,032 KB |
testcase_25 | AC | 967 ms
17,092 KB |
testcase_26 | AC | 958 ms
17,000 KB |
testcase_27 | AC | 956 ms
17,116 KB |
testcase_28 | AC | 959 ms
17,108 KB |
testcase_29 | TLE | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
ソースコード
class No697: height, width = 0, 0 cnt = 0 def __init__(self): self.height, self.width = map(int, input().split(" ")) # 高速化.1 内包表記 self.water_map = [list(map(int, input().split(" "))) for _ in range(self.height)] def solve(self): for h in range(self.height): for w in range(self.width): if self.water_map[h][w] == 1: search_queue = ((h, w),) while len(search_queue) != 0: copy_queue = search_queue search_queue = tuple() for py, px in copy_queue: search_dic = [(0, 1, 0, -1), (1, 0, -1, 0)] for i in range(4): vx = px + search_dic[0][i] vy = py + search_dic[1][i] if 0 <= vx < self.width and 0 <= vy < self.height: if not self.water_map[vy][vx] == 0: comp = (py + search_dic[1][i], px + search_dic[0][i]) if comp not in search_queue: search_queue += ((py + search_dic[1][i], px + search_dic[0][i]), ) self.water_map[py][px] = 0 self.cnt += 1 return self.cnt if __name__ == "__main__": que = No697() ans = que.solve() print(ans)