結果
問題 | No.124 門松列(3) |
ユーザー | yuyyuyu |
提出日時 | 2015-08-04 18:52:53 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 112 ms / 5,000 ms |
コード長 | 810 bytes |
コンパイル時間 | 1,212 ms |
コンパイル使用メモリ | 77,772 KB |
実行使用メモリ | 80,072 KB |
最終ジャッジ日時 | 2023-09-25 01:07:40 |
合計ジャッジ時間 | 3,823 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
79,620 KB |
testcase_01 | AC | 76 ms
76,328 KB |
testcase_02 | AC | 75 ms
76,288 KB |
testcase_03 | AC | 112 ms
80,072 KB |
testcase_04 | AC | 81 ms
78,712 KB |
testcase_05 | AC | 80 ms
78,752 KB |
testcase_06 | AC | 73 ms
76,820 KB |
testcase_07 | AC | 74 ms
76,196 KB |
testcase_08 | AC | 74 ms
76,524 KB |
testcase_09 | AC | 74 ms
76,456 KB |
testcase_10 | AC | 73 ms
76,416 KB |
testcase_11 | AC | 74 ms
76,544 KB |
testcase_12 | AC | 75 ms
76,724 KB |
testcase_13 | AC | 74 ms
76,472 KB |
testcase_14 | AC | 77 ms
76,740 KB |
testcase_15 | AC | 76 ms
76,568 KB |
testcase_16 | AC | 90 ms
79,440 KB |
testcase_17 | AC | 75 ms
76,564 KB |
testcase_18 | AC | 76 ms
76,480 KB |
testcase_19 | AC | 76 ms
76,544 KB |
testcase_20 | AC | 88 ms
79,336 KB |
testcase_21 | AC | 74 ms
76,464 KB |
testcase_22 | AC | 75 ms
76,428 KB |
testcase_23 | AC | 78 ms
78,564 KB |
testcase_24 | AC | 79 ms
78,668 KB |
testcase_25 | AC | 80 ms
78,732 KB |
testcase_26 | AC | 80 ms
78,932 KB |
testcase_27 | AC | 77 ms
77,628 KB |
testcase_28 | AC | 80 ms
78,888 KB |
testcase_29 | AC | 80 ms
78,884 KB |
ソースコード
dxdy=zip([-1,0,1,0],[0,1,0,-1]) def kadomatsu(a,b,c): if a==0 or b==0: return True else: if (a!=b and b!=c and c!=a) and not (a<b<c or a>b>c): return True else: return False W,H=map(int,raw_input().split()) M=[map(int,raw_input().split()) for _ 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: [bef,x,y]=que.pop(0) cur=M[y][x] if x==W-1 and y==H-1: print cost[bef][y][x] exit() for dx,dy in dxdy: nx,ny=x+dx,y+dy if not(0<=nx<W and 0<=ny<H):continue aft=M[ny][nx] if not kadomatsu(bef,cur,aft):continue if cost[cur][ny][nx]!=-1:continue cost[cur][ny][nx]=cost[bef][y][x]+1 que.append([cur,nx,ny]) print -1