結果
問題 | No.5006 Hidden Maze |
ユーザー | brthyyjp |
提出日時 | 2022-06-12 15:27:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 382 ms / 2,000 ms |
コード長 | 2,319 bytes |
コンパイル時間 | 260 ms |
実行使用メモリ | 99,944 KB |
スコア | 28,176 |
平均クエリ数 | 719.24 |
最終ジャッジ日時 | 2022-06-12 15:29:00 |
合計ジャッジ時間 | 35,800 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge16 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 258 ms
98,360 KB |
testcase_01 | AC | 341 ms
99,320 KB |
testcase_02 | AC | 170 ms
96,460 KB |
testcase_03 | AC | 354 ms
99,944 KB |
testcase_04 | AC | 370 ms
99,484 KB |
testcase_05 | AC | 345 ms
99,296 KB |
testcase_06 | AC | 344 ms
99,404 KB |
testcase_07 | AC | 348 ms
99,448 KB |
testcase_08 | AC | 357 ms
98,992 KB |
testcase_09 | AC | 342 ms
99,220 KB |
testcase_10 | AC | 180 ms
96,916 KB |
testcase_11 | AC | 346 ms
99,780 KB |
testcase_12 | AC | 338 ms
99,088 KB |
testcase_13 | AC | 243 ms
98,108 KB |
testcase_14 | AC | 335 ms
98,220 KB |
testcase_15 | AC | 346 ms
99,828 KB |
testcase_16 | AC | 338 ms
98,296 KB |
testcase_17 | AC | 234 ms
97,736 KB |
testcase_18 | AC | 333 ms
98,612 KB |
testcase_19 | AC | 343 ms
99,568 KB |
testcase_20 | AC | 230 ms
98,056 KB |
testcase_21 | AC | 338 ms
98,548 KB |
testcase_22 | AC | 167 ms
97,412 KB |
testcase_23 | AC | 235 ms
97,588 KB |
testcase_24 | AC | 334 ms
98,056 KB |
testcase_25 | AC | 349 ms
99,352 KB |
testcase_26 | AC | 340 ms
97,816 KB |
testcase_27 | AC | 341 ms
98,260 KB |
testcase_28 | AC | 341 ms
99,820 KB |
testcase_29 | AC | 171 ms
96,888 KB |
testcase_30 | AC | 261 ms
97,868 KB |
testcase_31 | AC | 358 ms
98,896 KB |
testcase_32 | AC | 342 ms
99,312 KB |
testcase_33 | AC | 265 ms
98,376 KB |
testcase_34 | AC | 214 ms
97,276 KB |
testcase_35 | AC | 353 ms
99,436 KB |
testcase_36 | AC | 221 ms
96,940 KB |
testcase_37 | AC | 339 ms
98,060 KB |
testcase_38 | AC | 343 ms
98,456 KB |
testcase_39 | AC | 214 ms
97,072 KB |
testcase_40 | AC | 163 ms
97,452 KB |
testcase_41 | AC | 212 ms
97,832 KB |
testcase_42 | AC | 222 ms
97,712 KB |
testcase_43 | AC | 349 ms
99,584 KB |
testcase_44 | AC | 345 ms
99,516 KB |
testcase_45 | AC | 382 ms
99,792 KB |
testcase_46 | AC | 347 ms
98,264 KB |
testcase_47 | AC | 300 ms
98,508 KB |
testcase_48 | AC | 336 ms
98,144 KB |
testcase_49 | AC | 327 ms
98,164 KB |
testcase_50 | AC | 348 ms
98,672 KB |
testcase_51 | AC | 171 ms
97,160 KB |
testcase_52 | AC | 208 ms
97,560 KB |
testcase_53 | AC | 337 ms
98,732 KB |
testcase_54 | AC | 355 ms
99,196 KB |
testcase_55 | AC | 191 ms
97,744 KB |
testcase_56 | AC | 221 ms
98,044 KB |
testcase_57 | AC | 344 ms
99,284 KB |
testcase_58 | AC | 338 ms
99,336 KB |
testcase_59 | AC | 354 ms
99,020 KB |
testcase_60 | AC | 157 ms
97,084 KB |
testcase_61 | AC | 226 ms
98,088 KB |
testcase_62 | AC | 330 ms
98,788 KB |
testcase_63 | AC | 356 ms
99,572 KB |
testcase_64 | AC | 350 ms
99,016 KB |
testcase_65 | AC | 176 ms
97,448 KB |
testcase_66 | AC | 163 ms
97,532 KB |
testcase_67 | AC | 350 ms
98,696 KB |
testcase_68 | AC | 324 ms
98,360 KB |
testcase_69 | AC | 335 ms
98,320 KB |
testcase_70 | AC | 253 ms
98,384 KB |
testcase_71 | AC | 229 ms
97,680 KB |
testcase_72 | AC | 290 ms
98,504 KB |
testcase_73 | AC | 339 ms
98,720 KB |
testcase_74 | AC | 352 ms
99,336 KB |
testcase_75 | AC | 346 ms
98,352 KB |
testcase_76 | AC | 343 ms
99,276 KB |
testcase_77 | AC | 341 ms
99,696 KB |
testcase_78 | AC | 336 ms
98,380 KB |
testcase_79 | AC | 315 ms
99,288 KB |
testcase_80 | AC | 163 ms
96,536 KB |
testcase_81 | AC | 282 ms
98,160 KB |
testcase_82 | AC | 332 ms
98,288 KB |
testcase_83 | AC | 165 ms
96,908 KB |
testcase_84 | AC | 159 ms
97,040 KB |
testcase_85 | AC | 361 ms
99,040 KB |
testcase_86 | AC | 340 ms
98,836 KB |
testcase_87 | AC | 332 ms
98,580 KB |
testcase_88 | AC | 345 ms
98,132 KB |
testcase_89 | AC | 341 ms
98,896 KB |
testcase_90 | AC | 348 ms
99,192 KB |
testcase_91 | AC | 156 ms
97,260 KB |
testcase_92 | AC | 360 ms
98,488 KB |
testcase_93 | AC | 323 ms
98,676 KB |
testcase_94 | AC | 328 ms
98,540 KB |
testcase_95 | AC | 351 ms
99,252 KB |
testcase_96 | AC | 155 ms
96,804 KB |
testcase_97 | AC | 331 ms
98,872 KB |
testcase_98 | AC | 335 ms
98,064 KB |
testcase_99 | AC | 325 ms
98,056 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 = 1001 cnt = 0 while cnt < maxT: 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//2): 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) reconst(s, max(v0, v1)) cnt += 2 else: break