結果

問題 No.340 雪の足跡
ユーザー LeonardoneLeonardone
提出日時 2016-01-30 06:51:32
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 7,172 KB
実行使用メモリ 34,752 KB
最終ジャッジ日時 2023-10-21 17:47:29
合計ジャッジ時間 7,111 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,780 KB
testcase_01 AC 12 ms
6,432 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 11 ms
6,432 KB
testcase_06 AC 12 ms
6,432 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 12 ms
6,432 KB
testcase_10 WA -
testcase_11 AC 29 ms
6,516 KB
testcase_12 AC 20 ms
6,528 KB
testcase_13 AC 28 ms
6,588 KB
testcase_14 AC 411 ms
8,352 KB
testcase_15 AC 518 ms
8,456 KB
testcase_16 AC 302 ms
7,444 KB
testcase_17 AC 728 ms
8,748 KB
testcase_18 AC 560 ms
8,752 KB
testcase_19 AC 719 ms
8,744 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
# ------------------------------------------------------
def gs():   return raw_input().strip()
def gi():   return int(gs())
def gss():  return gs().split()
def gis():  return map(int, gss())
def nmapf(n, f): return [f() for _ in range(n)]
def ngs(n): return nmapf(n, gs)
def ngi(n): return nmapf(n, gi)
def ngss(n): return nmapf(n, gss)
def ngis(n): return nmapf(n, gis)
def arr2d(h,w,v=0): return [[v] * w for _ in range(h)]
def divMod(v,d): w = v // d; return w, v - w * d
# ------------------------------------------------------


def solve():
    w, h, n = gis()
    hr = arr2d(h,w,False)
    vr = arr2d(h,w,False)
    f = arr2d(h,w,True)
    
    for _ in xrange(n):
        m = gi()
        b = gis()
        for i in xrange(1,m):
            b1 = max(b[i],b[i-1])
            b2 = min(b[i],b[i-1])
            b1y, b1x = divMod(b1,w)
            b2y, b2x = divMod(b2,w)
            if b1y == b2y:
                for x in xrange(b2x,b1x+1):
                    hr[b1y][x] = True
            elif b1x == b2x:
                for y in xrange(b2y,b1y+1):
                    vr[y][b1x] = True
    
    cu = [0]
    f[0][0] = False
    for i in xrange(h * w):
        nx = []
        for v in cu:
            y = v >> 10
            x = v & 1023
            if x == w - 1 and y == h - 1:
                print i
                return
            if x > 1 and f[y][x-1]:
                f[y][x-1] = False
                nx.append((y << 10) | (x - 1))
            if x < w - 1 and f[y][x+1]:
                f[y][x+1] = False
                nx.append((y << 10) | (x + 1))
            if y > 1 and f[y-1][x]:
                f[y-1][x] = False
                nx.append(((y - 1) << 10) | x)
            if y < h - 1 and f[y+1][x]:
                f[y+1][x] = False
                nx.append(((y + 1) << 10) | x)
        cu = nx
        if len(cu) == 0:
            break
    print 'Odekakedekinai..'
    
solve()
0