結果
問題 | No.340 雪の足跡 |
ユーザー |
![]() |
提出日時 | 2021-01-14 08:12:31 |
言語 | PyPy3 (7.3.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,230 Byte |
コンパイル時間 | 271 ms |
使用メモリ | 113,776 KB |
最終ジャッジ日時 | 2021-01-14 08:12:42 |
合計ジャッジ時間 | 10,496 ms |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
74,048 KB |
testcase_01 | AC | 57 ms
74,184 KB |
testcase_02 | AC | 58 ms
74,068 KB |
testcase_03 | AC | 59 ms
74,164 KB |
testcase_04 | AC | 58 ms
74,128 KB |
testcase_05 | AC | 63 ms
74,016 KB |
testcase_06 | AC | 60 ms
74,124 KB |
testcase_07 | AC | 61 ms
74,032 KB |
testcase_08 | AC | 59 ms
74,052 KB |
testcase_09 | AC | 59 ms
74,336 KB |
testcase_10 | AC | 59 ms
74,064 KB |
testcase_11 | WA | - |
testcase_12 | AC | 87 ms
80,376 KB |
testcase_13 | WA | - |
testcase_14 | AC | 137 ms
81,252 KB |
testcase_15 | WA | - |
testcase_16 | AC | 118 ms
81,116 KB |
testcase_17 | AC | 152 ms
84,944 KB |
testcase_18 | AC | 149 ms
83,604 KB |
testcase_19 | AC | 150 ms
85,292 KB |
testcase_20 | AC | 332 ms
109,220 KB |
testcase_21 | AC | 185 ms
80,276 KB |
testcase_22 | AC | 113 ms
97,600 KB |
testcase_23 | AC | 334 ms
105,336 KB |
testcase_24 | AC | 309 ms
108,948 KB |
testcase_25 | AC | 303 ms
105,892 KB |
testcase_26 | WA | - |
testcase_27 | AC | 84 ms
79,748 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 301 ms
97,952 KB |
testcase_31 | AC | 448 ms
109,772 KB |
testcase_32 | AC | 468 ms
112,440 KB |
testcase_33 | AC | 400 ms
110,912 KB |
testcase_34 | AC | 473 ms
112,500 KB |
testcase_35 | AC | 364 ms
113,776 KB |
testcase_36 | AC | 357 ms
113,600 KB |
ソースコード
import sys readline = sys.stdin.readline w,h,n = map(int,input().split()) b1 = [[0]*w for _ in range(h)] b2 = [[0]*h for _ in range(w)] for _ in range(n): m = int(readline()) t = list(map(int,input().split())) for i in range(m): x,y = t[i],t[i+1] if x > y: x,y = y,x if abs(x-y) < w: b1[x//w][x%w] += 1 b1[y//w][y%w] -= 1 else: b2[x%w][x//w] += 1 b2[y%w][y//w] -= 1 for i in range(h): for j in range(1,w): b1[i][j] += b1[i][j-1] for j in range(w): for i in range(1,h): b2[j][i] += b2[j][i-1] from collections import deque q = deque([(0,0)]) b = [[-1]*w for _ in range(h)] b[0][0] = 0 while q: vi,vj = q.popleft() d = b[vi][vj] if vj and b1[vi][vj-1] and b[vi][vj-1]==-1: b[vi][vj-1] = d+1 q.append((vi,vj-1)) if vj+1<w and b1[vi][vj] and b[vi][vj+1]==-1: b[vi][vj+1] = d+1 q.append((vi,vj+1)) if vi and b2[vj][vi-1] and b[vi-1][vj]==-1: b[vi-1][vj] = d+1 q.append((vi-1,vj)) if vi+1<w and b2[vj][vi] and b[vi+1][vj]==-1: b[vi+1][vj] = d+1 q.append((vi+1,vj)) print(b[h-1][w-1] if b[h-1][w-1] != -1 else "Odekakedekinai..")