結果
問題 | No.5006 Hidden Maze |
ユーザー | brthyyjp |
提出日時 | 2022-06-12 15:13:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 326 ms / 2,000 ms |
コード長 | 2,243 bytes |
コンパイル時間 | 616 ms |
実行使用メモリ | 99,460 KB |
スコア | 25,096 |
平均クエリ数 | 748.60 |
最終ジャッジ日時 | 2022-06-12 15:14:25 |
合計ジャッジ時間 | 30,784 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 283 ms
97,828 KB |
testcase_01 | AC | 261 ms
99,056 KB |
testcase_02 | AC | 222 ms
96,736 KB |
testcase_03 | AC | 192 ms
96,980 KB |
testcase_04 | AC | 279 ms
98,392 KB |
testcase_05 | AC | 269 ms
98,940 KB |
testcase_06 | AC | 273 ms
99,264 KB |
testcase_07 | AC | 270 ms
98,736 KB |
testcase_08 | AC | 274 ms
98,856 KB |
testcase_09 | AC | 265 ms
98,596 KB |
testcase_10 | AC | 194 ms
97,316 KB |
testcase_11 | AC | 197 ms
97,292 KB |
testcase_12 | AC | 276 ms
98,644 KB |
testcase_13 | AC | 285 ms
97,964 KB |
testcase_14 | AC | 262 ms
98,524 KB |
testcase_15 | AC | 267 ms
99,348 KB |
testcase_16 | AC | 257 ms
98,744 KB |
testcase_17 | AC | 281 ms
98,868 KB |
testcase_18 | AC | 255 ms
98,620 KB |
testcase_19 | AC | 274 ms
98,524 KB |
testcase_20 | AC | 192 ms
97,272 KB |
testcase_21 | AC | 278 ms
98,720 KB |
testcase_22 | AC | 167 ms
97,356 KB |
testcase_23 | AC | 164 ms
97,244 KB |
testcase_24 | AC | 274 ms
98,960 KB |
testcase_25 | AC | 280 ms
99,084 KB |
testcase_26 | AC | 278 ms
98,348 KB |
testcase_27 | AC | 281 ms
98,748 KB |
testcase_28 | AC | 281 ms
98,588 KB |
testcase_29 | AC | 255 ms
97,904 KB |
testcase_30 | AC | 179 ms
97,000 KB |
testcase_31 | AC | 280 ms
98,452 KB |
testcase_32 | AC | 265 ms
98,320 KB |
testcase_33 | AC | 280 ms
98,572 KB |
testcase_34 | AC | 184 ms
96,844 KB |
testcase_35 | AC | 205 ms
97,548 KB |
testcase_36 | AC | 157 ms
96,632 KB |
testcase_37 | AC | 258 ms
98,008 KB |
testcase_38 | AC | 263 ms
98,764 KB |
testcase_39 | AC | 185 ms
96,872 KB |
testcase_40 | AC | 191 ms
97,152 KB |
testcase_41 | AC | 177 ms
96,304 KB |
testcase_42 | AC | 285 ms
97,844 KB |
testcase_43 | AC | 269 ms
99,048 KB |
testcase_44 | AC | 160 ms
97,216 KB |
testcase_45 | AC | 299 ms
98,468 KB |
testcase_46 | AC | 246 ms
97,632 KB |
testcase_47 | AC | 184 ms
97,348 KB |
testcase_48 | AC | 275 ms
98,864 KB |
testcase_49 | AC | 260 ms
97,812 KB |
testcase_50 | AC | 290 ms
98,120 KB |
testcase_51 | AC | 282 ms
98,056 KB |
testcase_52 | AC | 303 ms
98,176 KB |
testcase_53 | AC | 273 ms
98,752 KB |
testcase_54 | AC | 279 ms
99,128 KB |
testcase_55 | AC | 192 ms
96,740 KB |
testcase_56 | AC | 270 ms
98,660 KB |
testcase_57 | AC | 267 ms
98,524 KB |
testcase_58 | AC | 286 ms
98,052 KB |
testcase_59 | AC | 201 ms
97,408 KB |
testcase_60 | AC | 157 ms
96,084 KB |
testcase_61 | AC | 204 ms
97,084 KB |
testcase_62 | AC | 276 ms
99,172 KB |
testcase_63 | AC | 268 ms
99,020 KB |
testcase_64 | AC | 294 ms
98,668 KB |
testcase_65 | AC | 312 ms
99,104 KB |
testcase_66 | AC | 187 ms
97,124 KB |
testcase_67 | AC | 270 ms
98,568 KB |
testcase_68 | AC | 278 ms
98,872 KB |
testcase_69 | AC | 275 ms
98,624 KB |
testcase_70 | AC | 189 ms
96,824 KB |
testcase_71 | AC | 196 ms
97,524 KB |
testcase_72 | AC | 278 ms
99,064 KB |
testcase_73 | AC | 271 ms
99,248 KB |
testcase_74 | AC | 269 ms
98,932 KB |
testcase_75 | AC | 287 ms
99,460 KB |
testcase_76 | AC | 326 ms
97,876 KB |
testcase_77 | AC | 276 ms
98,876 KB |
testcase_78 | AC | 262 ms
98,876 KB |
testcase_79 | AC | 260 ms
97,928 KB |
testcase_80 | AC | 164 ms
97,296 KB |
testcase_81 | AC | 269 ms
98,892 KB |
testcase_82 | AC | 303 ms
98,824 KB |
testcase_83 | AC | 172 ms
96,692 KB |
testcase_84 | AC | 157 ms
96,648 KB |
testcase_85 | AC | 269 ms
99,064 KB |
testcase_86 | AC | 278 ms
98,436 KB |
testcase_87 | AC | 264 ms
98,500 KB |
testcase_88 | AC | 264 ms
98,272 KB |
testcase_89 | AC | 265 ms
98,884 KB |
testcase_90 | AC | 271 ms
99,060 KB |
testcase_91 | AC | 197 ms
97,144 KB |
testcase_92 | AC | 282 ms
98,864 KB |
testcase_93 | AC | 270 ms
98,316 KB |
testcase_94 | AC | 261 ms
99,396 KB |
testcase_95 | AC | 270 ms
98,464 KB |
testcase_96 | AC | 163 ms
97,424 KB |
testcase_97 | AC | 269 ms
98,604 KB |
testcase_98 | AC | 271 ms
98,664 KB |
testcase_99 | AC | 280 ms
98,096 KB |
ソースコード
from collections import deque def query(s): print(''.join(s), flush = True) v = int(input()) if v == -1: exit() return v dys = (0, 1, 0, -1) dxs = (-1, 0, 1, 0) direcs = "LDRU" toid = {'L':0, 'D':1, 'R':2, 'U':3} def reconst(s, l): y, x = 0, 0 for i in range(l): dir = toid[s[i]] if dir == 0: ver[y][x] = 0 elif dir == 1: hor[y+1][x] = 0 elif dir == 2: ver[y][x+1] = 0 else: hor[y][x] = 0 dy, dx = dys[dir], dxs[dir] y, x = y+dy, x+dx dir = toid[s[l]] if dir == 0: ver[y][x] = 1 elif dir == 1: hor[y+1][x] = 1 elif dir == 2: ver[y][x+1] = 1 else: hor[y][x] = 1 h, w, p = map(int, input().split()) start = 0 goal = (h-1)*w+w-1 maxT = 1000 hor = [[-1]*w for i in range(h+1)] ver = [[-1]*(w+1) for i in range(h)] for x in range(w): hor[0][x] = 1 hor[h][x] = 1 for y in range(h): ver[y][0] = 1 ver[y][w] = 1 for iter in range(maxT//3): q = deque([]) q.append(0) prev = [-1]*(h*w) direction = [-1]*(h*w) visit = [False]*(h*w) visit[0] = True while q: v = q.popleft() y, x = divmod(v, w) for i in range(4): dy, dx = dys[i], dxs[i] ny = y + dy nx = x + dx if not (0 <= ny < h and 0 <= nx < w): continue if (dx==-1 and ver[y][x]!=1) or (dx==1 and ver[y][x+1] != 1) or (dy==-1 and hor[y][x]!=1) or (dy==1 and hor[y+1][x]!=1): nv = ny*w+nx if not visit[nv]: q.append(nv) prev[nv] = v direction[nv] = i visit[nv] = True if visit[goal]: cur = goal s = [] while cur != -1: if cur != start: dir = direction[cur] s.append(direcs[dir]) cur = prev[cur] s.reverse() v0 = query(s) v1 = query(s) v2 = query(s) reconst(s, max(v0, v1, v2)) else: s = ['D']*(h-1)+['R']*(w-1) v0 = query(s) v1 = query(s) v2 = query(s) reconst(s, max(v0, v1, v2))