提出 #43142753


ソースコード 拡げる

## ABC308D



h, w = map(int, input().split())


chars = [[] for _ in range(h + 2)]
chars[0] = ["'" for _ in range(w+2)]
chars[-1] = ["'" for _ in range(w+2)]
# print(chars)
for i in range(h):
    chars[i+1] = list(str(input().split()))[1:-1]
    
# print(chars)

snukes = {"s":"n","n":"u","u":"k","k":"e","e":"s"}

def dfs(G, start, visited=None):

    if start == ((h-1)*1000+w-1):
        print("Yes")
        exit()
    if start in G.keys():
        if visited is None:
            visited = set()
        visited.add(start)
        for next_node in G[start]:
            dfs(G,next_node,visited)
    return visited

direction = {}
for i in range(h):
    for j in range(w):
        if chars[i+1][j+1] in snukes.keys():
            nxt = snukes[chars[i+1][j+1]]
            # print(i,j,chars[i+1][j+1],nxt)
            if chars[i+1][j+2] == nxt:
                if (i*1000+j) not in direction.keys():
                    direction[(i*1000+j)] = set()
                direction[(i*1000+j)].add((i*1000+j+1))
            if chars[i+1][j+0] == nxt:
                if (i*1000+j) not in direction.keys():
                    direction[(i*1000+j)] = set()
                direction[(i*1000+j)].add((i*1000+j-1))
            if chars[i+2][j+1] == nxt:
                if (i*1000+j) not in direction.keys():
                    direction[(i*1000+j)] = set()
                direction[(i*1000+j)].add((i*1000+1*1000+j))
            if chars[i+0][j+1] == nxt:
                if (i*1000+j) not in direction.keys():
                    direction[(i*1000+j)] = set()
                direction[(i*1000+j)].add((i*1000+1*1000+j))

# print(direction)
if direction =={}:
    print("No")
    exit()
dfs(direction, 0)

print("No")

提出情報

提出日時
問題 D - Snuke Maze
ユーザ toyko
言語 PyPy3 (7.3.0)
得点 0
コード長 1776 Byte
結果 RE
実行時間 2211 ms
メモリ 223748 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 3
AC × 18
WA × 2
TLE × 14
RE × 2
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 64 ms 62096 KiB
00_sample_01.txt AC 47 ms 61928 KiB
00_sample_02.txt AC 51 ms 62148 KiB
01_random_00.txt AC 64 ms 67056 KiB
01_random_01.txt AC 88 ms 77232 KiB
01_random_02.txt AC 159 ms 106240 KiB
01_random_03.txt AC 104 ms 79300 KiB
01_random_04.txt AC 128 ms 89708 KiB
01_random_05.txt AC 51 ms 62432 KiB
01_random_06.txt AC 89 ms 74648 KiB
01_random_07.txt AC 108 ms 80588 KiB
02_random2_00.txt TLE 2210 ms 175012 KiB
02_random2_01.txt TLE 2211 ms 207236 KiB
02_random2_02.txt TLE 2210 ms 163172 KiB
02_random2_03.txt TLE 2211 ms 183252 KiB
02_random2_04.txt AC 250 ms 159928 KiB
02_random2_05.txt AC 244 ms 160456 KiB
02_random2_06.txt TLE 2210 ms 176992 KiB
02_random2_07.txt TLE 2211 ms 189284 KiB
02_random2_08.txt WA 250 ms 160584 KiB
02_random2_09.txt AC 237 ms 159772 KiB
02_random2_10.txt TLE 2210 ms 163108 KiB
02_random2_11.txt TLE 2210 ms 174600 KiB
02_random2_12.txt TLE 2211 ms 186356 KiB
02_random2_13.txt TLE 2210 ms 176588 KiB
02_random2_14.txt AC 258 ms 159064 KiB
02_random2_15.txt WA 235 ms 160548 KiB
02_random2_16.txt AC 313 ms 160980 KiB
02_random2_17.txt TLE 2211 ms 182896 KiB
02_random2_18.txt TLE 2211 ms 187428 KiB
02_random2_19.txt TLE 2211 ms 180740 KiB
03_handmade_00.txt AC 67 ms 62172 KiB
03_handmade_01.txt AC 211 ms 159456 KiB
03_handmade_02.txt TLE 2211 ms 223748 KiB
03_handmade_03.txt RE 301 ms 171048 KiB
03_handmade_04.txt RE 281 ms 171112 KiB