結果
問題 | No.5006 Hidden Maze |
ユーザー | titan23 |
提出日時 | 2022-06-12 14:34:00 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,360 bytes |
コンパイル時間 | 570 ms |
実行使用メモリ | 101,176 KB |
スコア | 0 |
平均クエリ数 | 1.00 |
最終ジャッジ日時 | 2022-06-12 14:34:26 |
合計ジャッジ時間 | 23,589 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | RE | - |
testcase_89 | RE | - |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | RE | - |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | RE | - |
testcase_96 | RE | - |
testcase_97 | RE | - |
testcase_98 | RE | - |
testcase_99 | RE | - |
ソースコード
import sys import math from bisect import bisect_right, bisect_left from itertools import * from collections import * from heapq import heapify, heappush, heappop inf = float('inf') # mod = 1000000007 # mod = 998244353 input = lambda: sys.stdin.readline().rstrip() def error(*args, end='\n'): print(*args, end=end, file=sys.stderr) # sys.setrecursionlimit(10**6) ################## def can_move(x, y, d): if d == 'U': if y and not v[y-1][x]: return 1 elif d == 'D': if y < 19 and not v[y][x]: return 1 elif d == 'L': if x and not h[y][x-1]: return 1 elif d == 'R': if x < 19 and not h[y][x]: return 1 return 0 H, W, P = map(int, input().split()) h = [[-1]*W for _ in range(H)] v = [[-1]*W for _ in range(W)] DIRECT = ['U', 'D', 'L', 'R'] dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] def bfs(si, sj): dist = [[-1]*20 for _ in range_20] dq = deque([(si, sj)]) dist[si][sj] = 0 while dq: nowy, nowx = dq.popleft() d = dist[nowy][nowx] + 1 if can_move(nowx, nowy, 'D') and dist[nowy+1][nowx] == -1: dq.append((nowy+1, nowx)) dist[nowy+1][nowx] = d if can_move(nowx, nowy, 'U') and dist[nowy-1][nowx] == -1: dq.append((nowy-1, nowx)) dist[nowy-1][nowx] = d if can_move(nowx, nowy, 'R') and dist[nowy][nowx+1] == -1: dq.append((nowy, nowx+1)) dist[nowy][nowx+1] = d if can_move(nowx, nowy, 'L') and dist[nowy][nowx-1] == -1: dq.append((nowy, nowx-1)) dist[nowy][nowx-1] = d return dist def get_root(dist): root = [] nowx, nowy = 19, 19 while True: d = dist[nowy][nowx] if d == 0: break if nowy+1 < 20 and v[nowy][nowx] == 0 and dist[nowy+1][nowx] == d-1: root.append('U') nowy += 1 elif nowy-1 >= 0 and v[nowy-1][nowx] == 0 and dist[nowy-1][nowx] == d-1: root.append('D') nowy -= 1 elif nowx+1 < 20 and h[nowy][nowx] == 0 and dist[nowy][nowx+1] == d-1: root.append('L') nowx += 1 elif nowx-1 >= 0 and h[nowy][nowx-1] == 0 and dist[nowy][nowx-1] == d-1: root.append('R') nowx -= 1 return list(reversed(root)) ok = [] trynum = 0 while trynum < 1000: dist = bfs(0, 0) # solve? if dist[19][19] != -1: print(get_root(dist), flush=True) input() break # search res = [] print(''.join(res), flush=True) resnum = int(input())