結果
問題 | No.5006 Hidden Maze |
ユーザー | brthyyjp |
提出日時 | 2022-06-12 16:08:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 395 ms / 2,000 ms |
コード長 | 2,349 bytes |
コンパイル時間 | 237 ms |
実行使用メモリ | 99,768 KB |
スコア | 36,268 |
平均クエリ数 | 638.32 |
最終ジャッジ日時 | 2022-06-12 16:17:04 |
合計ジャッジ時間 | 32,572 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 278 ms
98,344 KB |
testcase_01 | AC | 323 ms
99,084 KB |
testcase_02 | AC | 195 ms
96,768 KB |
testcase_03 | AC | 184 ms
97,852 KB |
testcase_04 | AC | 321 ms
99,108 KB |
testcase_05 | AC | 333 ms
99,068 KB |
testcase_06 | AC | 334 ms
99,176 KB |
testcase_07 | AC | 328 ms
98,968 KB |
testcase_08 | AC | 322 ms
98,704 KB |
testcase_09 | AC | 313 ms
99,128 KB |
testcase_10 | AC | 159 ms
97,128 KB |
testcase_11 | AC | 190 ms
97,680 KB |
testcase_12 | AC | 334 ms
98,220 KB |
testcase_13 | AC | 344 ms
98,312 KB |
testcase_14 | AC | 356 ms
98,816 KB |
testcase_15 | AC | 335 ms
99,076 KB |
testcase_16 | AC | 330 ms
99,052 KB |
testcase_17 | AC | 236 ms
98,404 KB |
testcase_18 | AC | 352 ms
98,536 KB |
testcase_19 | AC | 351 ms
98,548 KB |
testcase_20 | AC | 179 ms
97,528 KB |
testcase_21 | AC | 337 ms
98,980 KB |
testcase_22 | AC | 159 ms
97,384 KB |
testcase_23 | AC | 157 ms
97,996 KB |
testcase_24 | AC | 218 ms
97,776 KB |
testcase_25 | AC | 317 ms
98,540 KB |
testcase_26 | AC | 324 ms
97,940 KB |
testcase_27 | AC | 357 ms
98,088 KB |
testcase_28 | AC | 342 ms
99,264 KB |
testcase_29 | AC | 201 ms
97,360 KB |
testcase_30 | AC | 178 ms
96,572 KB |
testcase_31 | AC | 294 ms
98,892 KB |
testcase_32 | AC | 325 ms
98,552 KB |
testcase_33 | AC | 283 ms
98,828 KB |
testcase_34 | AC | 171 ms
97,020 KB |
testcase_35 | AC | 184 ms
97,712 KB |
testcase_36 | AC | 149 ms
97,364 KB |
testcase_37 | AC | 320 ms
98,308 KB |
testcase_38 | AC | 317 ms
98,652 KB |
testcase_39 | AC | 179 ms
97,676 KB |
testcase_40 | AC | 183 ms
97,696 KB |
testcase_41 | AC | 166 ms
97,024 KB |
testcase_42 | AC | 342 ms
98,592 KB |
testcase_43 | AC | 337 ms
98,872 KB |
testcase_44 | AC | 194 ms
97,108 KB |
testcase_45 | AC | 395 ms
98,944 KB |
testcase_46 | AC | 332 ms
99,060 KB |
testcase_47 | AC | 178 ms
97,088 KB |
testcase_48 | AC | 327 ms
98,808 KB |
testcase_49 | AC | 302 ms
98,648 KB |
testcase_50 | AC | 310 ms
99,768 KB |
testcase_51 | AC | 258 ms
98,084 KB |
testcase_52 | AC | 268 ms
97,912 KB |
testcase_53 | AC | 334 ms
98,424 KB |
testcase_54 | AC | 327 ms
98,692 KB |
testcase_55 | AC | 278 ms
98,160 KB |
testcase_56 | AC | 221 ms
98,496 KB |
testcase_57 | AC | 366 ms
98,596 KB |
testcase_58 | AC | 343 ms
98,892 KB |
testcase_59 | AC | 177 ms
97,748 KB |
testcase_60 | AC | 147 ms
97,232 KB |
testcase_61 | AC | 184 ms
97,628 KB |
testcase_62 | AC | 346 ms
99,008 KB |
testcase_63 | AC | 310 ms
98,504 KB |
testcase_64 | AC | 330 ms
98,792 KB |
testcase_65 | AC | 324 ms
98,524 KB |
testcase_66 | AC | 178 ms
97,236 KB |
testcase_67 | AC | 237 ms
97,968 KB |
testcase_68 | AC | 312 ms
99,168 KB |
testcase_69 | AC | 317 ms
98,896 KB |
testcase_70 | AC | 178 ms
97,372 KB |
testcase_71 | AC | 175 ms
97,352 KB |
testcase_72 | AC | 258 ms
98,524 KB |
testcase_73 | AC | 376 ms
98,532 KB |
testcase_74 | AC | 313 ms
98,504 KB |
testcase_75 | AC | 308 ms
98,648 KB |
testcase_76 | AC | 343 ms
99,068 KB |
testcase_77 | AC | 364 ms
98,172 KB |
testcase_78 | AC | 326 ms
98,336 KB |
testcase_79 | AC | 304 ms
98,760 KB |
testcase_80 | AC | 154 ms
97,372 KB |
testcase_81 | AC | 215 ms
97,828 KB |
testcase_82 | AC | 249 ms
98,876 KB |
testcase_83 | AC | 164 ms
97,328 KB |
testcase_84 | AC | 154 ms
97,356 KB |
testcase_85 | AC | 326 ms
99,040 KB |
testcase_86 | AC | 254 ms
98,316 KB |
testcase_87 | AC | 325 ms
98,728 KB |
testcase_88 | AC | 318 ms
98,608 KB |
testcase_89 | AC | 328 ms
98,284 KB |
testcase_90 | AC | 238 ms
97,928 KB |
testcase_91 | AC | 172 ms
97,312 KB |
testcase_92 | AC | 336 ms
98,424 KB |
testcase_93 | AC | 212 ms
98,316 KB |
testcase_94 | AC | 317 ms
98,808 KB |
testcase_95 | AC | 332 ms
98,792 KB |
testcase_96 | AC | 157 ms
96,768 KB |
testcase_97 | AC | 331 ms
98,560 KB |
testcase_98 | AC | 330 ms
99,068 KB |
testcase_99 | AC | 323 ms
99,104 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//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)) cnt += 3 else: break