結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー | hir355 |
提出日時 | 2022-05-20 22:18:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,031 ms / 3,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 81,584 KB |
実行使用メモリ | 99,800 KB |
最終ジャッジ日時 | 2023-10-20 13:02:31 |
合計ジャッジ時間 | 8,873 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,400 KB |
testcase_01 | AC | 44 ms
53,400 KB |
testcase_02 | AC | 41 ms
53,400 KB |
testcase_03 | AC | 41 ms
53,400 KB |
testcase_04 | AC | 41 ms
53,400 KB |
testcase_05 | AC | 41 ms
53,400 KB |
testcase_06 | AC | 40 ms
53,400 KB |
testcase_07 | AC | 409 ms
80,568 KB |
testcase_08 | AC | 82 ms
76,180 KB |
testcase_09 | AC | 442 ms
80,632 KB |
testcase_10 | AC | 491 ms
80,720 KB |
testcase_11 | AC | 523 ms
80,900 KB |
testcase_12 | AC | 514 ms
81,504 KB |
testcase_13 | AC | 498 ms
80,672 KB |
testcase_14 | AC | 649 ms
99,796 KB |
testcase_15 | AC | 652 ms
99,800 KB |
testcase_16 | AC | 73 ms
76,640 KB |
testcase_17 | AC | 1,031 ms
95,956 KB |
testcase_18 | AC | 70 ms
76,640 KB |
testcase_19 | AC | 38 ms
53,400 KB |
testcase_20 | AC | 39 ms
53,400 KB |
testcase_21 | AC | 39 ms
53,400 KB |
testcase_22 | AC | 719 ms
89,668 KB |
testcase_23 | AC | 40 ms
53,400 KB |
testcase_24 | AC | 301 ms
80,416 KB |
testcase_25 | AC | 446 ms
81,084 KB |
ソースコード
import heapq dxdy = ((0, 1), (0, -1), (1, 0), (-1, 0)) h, w, x, y = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(h)] d = [[0] * w for _ in range(h)] d[x - 1][y - 1] = 1 hq = [(a[x - 1][y - 1], x - 1, y - 1)] t = 0 cnt = 0 while hq: p, x, y = heapq.heappop(hq) if cnt > 0 and t <= a[x][y]: print('No') exit(0) cnt += 1 t += a[x][y] for dx, dy in dxdy: if 0 <= x + dx < h and 0 <= y + dy < w and d[x + dx][y + dy] == 0: d[x + dx][y + dy] = 1 heapq.heappush(hq, (a[x + dx][y + dy], x + dx, y + dy)) print('Yes')