結果
問題 | No.5006 Hidden Maze |
ユーザー | brthyyjp |
提出日時 | 2022-06-12 15:41:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 382 ms / 2,000 ms |
コード長 | 2,370 bytes |
コンパイル時間 | 260 ms |
実行使用メモリ | 100,564 KB |
スコア | 8,402 |
平均クエリ数 | 916.98 |
最終ジャッジ日時 | 2022-06-12 15:42:01 |
合計ジャッジ時間 | 39,772 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 363 ms
98,444 KB |
testcase_01 | AC | 347 ms
98,220 KB |
testcase_02 | AC | 347 ms
99,656 KB |
testcase_03 | AC | 350 ms
99,148 KB |
testcase_04 | AC | 362 ms
100,040 KB |
testcase_05 | AC | 335 ms
99,064 KB |
testcase_06 | AC | 351 ms
99,280 KB |
testcase_07 | AC | 352 ms
99,140 KB |
testcase_08 | AC | 353 ms
99,508 KB |
testcase_09 | AC | 371 ms
99,840 KB |
testcase_10 | AC | 357 ms
99,372 KB |
testcase_11 | AC | 364 ms
98,432 KB |
testcase_12 | AC | 355 ms
99,696 KB |
testcase_13 | AC | 360 ms
99,464 KB |
testcase_14 | AC | 322 ms
98,732 KB |
testcase_15 | AC | 363 ms
99,604 KB |
testcase_16 | AC | 369 ms
98,884 KB |
testcase_17 | AC | 177 ms
96,904 KB |
testcase_18 | AC | 382 ms
99,620 KB |
testcase_19 | AC | 351 ms
99,996 KB |
testcase_20 | AC | 343 ms
99,724 KB |
testcase_21 | AC | 345 ms
99,632 KB |
testcase_22 | AC | 145 ms
96,524 KB |
testcase_23 | AC | 346 ms
99,984 KB |
testcase_24 | AC | 355 ms
99,300 KB |
testcase_25 | AC | 352 ms
99,904 KB |
testcase_26 | AC | 337 ms
99,284 KB |
testcase_27 | AC | 354 ms
99,716 KB |
testcase_28 | AC | 347 ms
100,052 KB |
testcase_29 | AC | 356 ms
99,692 KB |
testcase_30 | AC | 367 ms
99,388 KB |
testcase_31 | AC | 348 ms
99,196 KB |
testcase_32 | AC | 344 ms
100,044 KB |
testcase_33 | AC | 356 ms
99,420 KB |
testcase_34 | AC | 362 ms
98,428 KB |
testcase_35 | AC | 353 ms
99,876 KB |
testcase_36 | AC | 201 ms
97,232 KB |
testcase_37 | AC | 344 ms
99,116 KB |
testcase_38 | AC | 371 ms
99,320 KB |
testcase_39 | AC | 356 ms
100,564 KB |
testcase_40 | AC | 355 ms
99,532 KB |
testcase_41 | AC | 200 ms
97,452 KB |
testcase_42 | AC | 347 ms
100,244 KB |
testcase_43 | AC | 364 ms
99,920 KB |
testcase_44 | AC | 353 ms
100,076 KB |
testcase_45 | AC | 360 ms
100,216 KB |
testcase_46 | AC | 352 ms
99,584 KB |
testcase_47 | AC | 352 ms
100,256 KB |
testcase_48 | AC | 326 ms
98,844 KB |
testcase_49 | AC | 344 ms
99,548 KB |
testcase_50 | AC | 326 ms
98,392 KB |
testcase_51 | AC | 358 ms
99,536 KB |
testcase_52 | AC | 359 ms
99,292 KB |
testcase_53 | AC | 344 ms
100,256 KB |
testcase_54 | AC | 331 ms
99,364 KB |
testcase_55 | AC | 354 ms
100,188 KB |
testcase_56 | AC | 218 ms
97,484 KB |
testcase_57 | AC | 354 ms
99,752 KB |
testcase_58 | AC | 365 ms
99,744 KB |
testcase_59 | AC | 359 ms
99,096 KB |
testcase_60 | AC | 206 ms
98,016 KB |
testcase_61 | AC | 324 ms
98,780 KB |
testcase_62 | AC | 337 ms
99,488 KB |
testcase_63 | AC | 359 ms
98,504 KB |
testcase_64 | AC | 347 ms
98,664 KB |
testcase_65 | AC | 375 ms
99,316 KB |
testcase_66 | AC | 347 ms
99,552 KB |
testcase_67 | AC | 348 ms
99,876 KB |
testcase_68 | AC | 350 ms
99,724 KB |
testcase_69 | AC | 346 ms
99,508 KB |
testcase_70 | AC | 366 ms
99,264 KB |
testcase_71 | AC | 372 ms
99,316 KB |
testcase_72 | AC | 347 ms
99,364 KB |
testcase_73 | AC | 326 ms
98,600 KB |
testcase_74 | AC | 366 ms
99,688 KB |
testcase_75 | AC | 360 ms
99,568 KB |
testcase_76 | AC | 361 ms
99,444 KB |
testcase_77 | AC | 357 ms
99,760 KB |
testcase_78 | AC | 344 ms
99,084 KB |
testcase_79 | AC | 356 ms
99,432 KB |
testcase_80 | AC | 358 ms
100,068 KB |
testcase_81 | AC | 329 ms
98,184 KB |
testcase_82 | AC | 350 ms
99,772 KB |
testcase_83 | AC | 212 ms
97,576 KB |
testcase_84 | AC | 213 ms
97,672 KB |
testcase_85 | AC | 364 ms
99,880 KB |
testcase_86 | AC | 354 ms
99,780 KB |
testcase_87 | AC | 326 ms
98,232 KB |
testcase_88 | AC | 358 ms
99,920 KB |
testcase_89 | AC | 369 ms
98,628 KB |
testcase_90 | AC | 352 ms
99,680 KB |
testcase_91 | AC | 331 ms
99,456 KB |
testcase_92 | AC | 362 ms
99,048 KB |
testcase_93 | AC | 352 ms
100,168 KB |
testcase_94 | AC | 361 ms
98,276 KB |
testcase_95 | AC | 367 ms
98,908 KB |
testcase_96 | AC | 150 ms
96,208 KB |
testcase_97 | AC | 344 ms
99,356 KB |
testcase_98 | AC | 357 ms
99,236 KB |
testcase_99 | AC | 363 ms
99,472 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): 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) v = query(s) #reconst(s, max(v0, v1)) reconst(s, v) cnt += 1 else: break