結果
問題 | No.340 雪の足跡 |
ユーザー | mkawa2 |
提出日時 | 2022-01-23 13:45:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,755 bytes |
コンパイル時間 | 1,352 ms |
コンパイル使用メモリ | 86,752 KB |
実行使用メモリ | 111,952 KB |
最終ジャッジ日時 | 2023-08-19 18:31:00 |
合計ジャッジ時間 | 16,723 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 104 ms
71,500 KB |
testcase_01 | AC | 120 ms
71,380 KB |
testcase_02 | AC | 106 ms
71,576 KB |
testcase_03 | AC | 109 ms
71,676 KB |
testcase_04 | AC | 106 ms
71,540 KB |
testcase_05 | AC | 101 ms
71,368 KB |
testcase_06 | AC | 106 ms
71,420 KB |
testcase_07 | AC | 109 ms
71,320 KB |
testcase_08 | AC | 109 ms
71,324 KB |
testcase_09 | AC | 101 ms
71,696 KB |
testcase_10 | AC | 109 ms
71,624 KB |
testcase_11 | WA | - |
testcase_12 | AC | 134 ms
77,536 KB |
testcase_13 | WA | - |
testcase_14 | AC | 208 ms
79,196 KB |
testcase_15 | WA | - |
testcase_16 | AC | 183 ms
78,612 KB |
testcase_17 | AC | 215 ms
79,956 KB |
testcase_18 | AC | 211 ms
79,736 KB |
testcase_19 | AC | 215 ms
80,124 KB |
testcase_20 | AC | 547 ms
89,780 KB |
testcase_21 | AC | 415 ms
78,420 KB |
testcase_22 | AC | 123 ms
79,360 KB |
testcase_23 | AC | 582 ms
87,552 KB |
testcase_24 | AC | 475 ms
87,312 KB |
testcase_25 | AC | 492 ms
88,688 KB |
testcase_26 | WA | - |
testcase_27 | AC | 119 ms
77,352 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 543 ms
90,012 KB |
testcase_31 | AC | 851 ms
104,896 KB |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | AC | 794 ms
96,792 KB |
testcase_36 | AC | 883 ms
97,336 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 md = 998244353 from collections import deque w, h, n = LI() row = [0]*h col = [0]*w for _ in range(n): m = II() bb = LI() for k in range(m): i, j = divmod(bb[k], w) s, t = divmod(bb[k+1], w) if i == s: if j > t: j, t = t, j row[i] |= (1 << t-j)-1 << j else: if i > s: i, s = s, i col[j] |= (1 << s-i)-1 << i # for a in row: print(bin(a)[2:].zfill(w)) # for a in col: print(bin(a)[2:].zfill(h)) def push(ij): dist[ij] = d+1 q.append(ij) dist = [-1]*h*w q = deque([0]) dist[0] = 0 while q: ij = q.popleft() d = dist[ij] i, j = divmod(ij, w) if j and row[i] >> j-1 & 1 and dist[ij-1] == -1: push(ij-1) if j+1 < w and row[i] >> j & 1 and dist[ij+1] == -1: push(ij+1) if i and col[j] >> i-1 & 1 and dist[ij-w] == -1: push(ij-w) if i+1 < w and col[j] >> i & 1 and dist[ij+w] == -1: push(ij+w) # pDB(i,j,dist) ans = dist[-1] if ans == -1: ans = "Odekakedekinai.." print(ans)