結果
問題 | No.124 門松列(3) |
ユーザー | yuyyuyu |
提出日時 | 2015-07-30 14:29:58 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 132 ms / 5,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 1,629 ms |
コンパイル使用メモリ | 77,476 KB |
実行使用メモリ | 80,964 KB |
最終ジャッジ日時 | 2023-09-24 22:15:29 |
合計ジャッジ時間 | 4,922 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 101 ms
79,420 KB |
testcase_01 | AC | 78 ms
76,408 KB |
testcase_02 | AC | 77 ms
76,432 KB |
testcase_03 | AC | 132 ms
80,964 KB |
testcase_04 | AC | 84 ms
78,728 KB |
testcase_05 | AC | 84 ms
78,368 KB |
testcase_06 | AC | 75 ms
76,092 KB |
testcase_07 | AC | 77 ms
76,220 KB |
testcase_08 | AC | 76 ms
76,280 KB |
testcase_09 | AC | 75 ms
76,412 KB |
testcase_10 | AC | 77 ms
76,216 KB |
testcase_11 | AC | 76 ms
76,356 KB |
testcase_12 | AC | 76 ms
76,116 KB |
testcase_13 | AC | 75 ms
76,420 KB |
testcase_14 | AC | 79 ms
76,416 KB |
testcase_15 | AC | 77 ms
76,252 KB |
testcase_16 | AC | 94 ms
79,256 KB |
testcase_17 | AC | 78 ms
76,476 KB |
testcase_18 | AC | 75 ms
76,564 KB |
testcase_19 | AC | 78 ms
76,428 KB |
testcase_20 | AC | 89 ms
79,196 KB |
testcase_21 | AC | 76 ms
76,436 KB |
testcase_22 | AC | 78 ms
76,244 KB |
testcase_23 | AC | 82 ms
78,664 KB |
testcase_24 | AC | 82 ms
78,996 KB |
testcase_25 | AC | 83 ms
78,616 KB |
testcase_26 | AC | 82 ms
78,780 KB |
testcase_27 | AC | 80 ms
77,452 KB |
testcase_28 | AC | 84 ms
78,440 KB |
testcase_29 | AC | 84 ms
78,524 KB |
ソースコード
def isKadomatsu(a,b,c): if a == 0 or b == 0: return True return b < a < c or b < c < a or a < c < b or c < a < b dxdy=zip([-1,0,1,0],[0,1,0,-1]) W,H=map(int,raw_input().split()) M=[map(int,raw_input().split()) for i in xrange(H)] que=[[0,0,0]] cost=[[[-1]*W for _ in xrange(H)] for i in xrange(10)] cost[0][0][0]=0 while que: w,h,bef=que.pop(0) if w==W-1 and h==H-1: print cost[bef][h][w] break cur=M[h][w] for dx,dy in dxdy: nw,nh=w+dx,h+dy if not (0<=nw<W and 0<=nh<H):continue aft=M[nh][nw] if not (isKadomatsu(bef,cur,aft)):continue if cost[cur][nh][nw]!=-1:continue cost[cur][nh][nw]=cost[bef][h][w]+1 que.append([nw,nh,cur]) else: print -1