結果
問題 | No.5006 Hidden Maze |
ユーザー | netyo715 |
提出日時 | 2022-06-12 17:58:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,075 bytes |
コンパイル時間 | 242 ms |
実行使用メモリ | 141,596 KB |
スコア | 16,012 |
平均クエリ数 | 50.09 |
最終ジャッジ日時 | 2022-06-12 18:00:35 |
合計ジャッジ時間 | 96,559 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | AC | 1,015 ms
111,680 KB |
testcase_03 | AC | 1,295 ms
109,384 KB |
testcase_04 | AC | 898 ms
107,796 KB |
testcase_05 | TLE | - |
testcase_06 | AC | 499 ms
103,468 KB |
testcase_07 | AC | 1,024 ms
109,672 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 587 ms
106,948 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,438 ms
108,924 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 638 ms
105,348 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 1,015 ms
109,048 KB |
testcase_16 | AC | 393 ms
103,724 KB |
testcase_17 | AC | 485 ms
106,160 KB |
testcase_18 | TLE | - |
testcase_19 | AC | 594 ms
106,036 KB |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | AC | 817 ms
107,824 KB |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | AC | 408 ms
102,584 KB |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | AC | 396 ms
103,908 KB |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | AC | 1,704 ms
111,384 KB |
testcase_32 | TLE | - |
testcase_33 | AC | 1,551 ms
110,376 KB |
testcase_34 | AC | 822 ms
106,816 KB |
testcase_35 | AC | 759 ms
106,976 KB |
testcase_36 | AC | 642 ms
106,428 KB |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | AC | 229 ms
102,088 KB |
testcase_40 | AC | 472 ms
106,676 KB |
testcase_41 | TLE | - |
testcase_42 | TLE | - |
testcase_43 | TLE | - |
testcase_44 | AC | 369 ms
105,264 KB |
testcase_45 | TLE | - |
testcase_46 | TLE | - |
testcase_47 | AC | 608 ms
105,656 KB |
testcase_48 | AC | 702 ms
104,608 KB |
testcase_49 | TLE | - |
testcase_50 | AC | 612 ms
106,732 KB |
testcase_51 | TLE | - |
testcase_52 | TLE | - |
testcase_53 | TLE | - |
testcase_54 | AC | 471 ms
104,676 KB |
testcase_55 | AC | 938 ms
107,636 KB |
testcase_56 | AC | 697 ms
107,256 KB |
testcase_57 | AC | 1,175 ms
109,768 KB |
testcase_58 | AC | 1,670 ms
113,324 KB |
testcase_59 | AC | 528 ms
105,016 KB |
testcase_60 | AC | 1,004 ms
109,204 KB |
testcase_61 | AC | 137 ms
96,768 KB |
testcase_62 | TLE | - |
testcase_63 | TLE | - |
testcase_64 | TLE | - |
testcase_65 | AC | 600 ms
105,876 KB |
testcase_66 | AC | 941 ms
108,304 KB |
testcase_67 | TLE | - |
testcase_68 | TLE | - |
testcase_69 | AC | 641 ms
104,280 KB |
testcase_70 | AC | 544 ms
104,920 KB |
testcase_71 | AC | 449 ms
104,376 KB |
testcase_72 | AC | 599 ms
107,464 KB |
testcase_73 | TLE | - |
testcase_74 | AC | 1,041 ms
109,704 KB |
testcase_75 | TLE | - |
testcase_76 | AC | 1,563 ms
114,460 KB |
testcase_77 | TLE | - |
testcase_78 | TLE | - |
testcase_79 | TLE | - |
testcase_80 | TLE | - |
testcase_81 | TLE | - |
testcase_82 | AC | 1,676 ms
110,640 KB |
testcase_83 | AC | 307 ms
102,296 KB |
testcase_84 | AC | 1,047 ms
109,516 KB |
testcase_85 | TLE | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
testcase_94 | -- | - |
testcase_95 | -- | - |
testcase_96 | -- | - |
testcase_97 | -- | - |
testcase_98 | -- | - |
testcase_99 | -- | - |
ソースコード
from heapq import heapify, heappop as pop, heappush as push from random import sample, randint D = ((-1, 0), (0, -1), (0, 1), (1, 0)) def solve(H, W, P): stop_cnt = [[0]*(H*W) for _ in range(H*W)] is_empty = [[False]*(H*W) for _ in range(H*W)] def rc2idx(row, col): return row*W+col def idx2rc(idx): return idx//W, idx%W def is_empty_idx(idx1, idx2): return is_empty[idx1][idx2] def is_empty_rc(row1, col1, row2, col2): return is_empty_idx(rc2idx(row1, col1), rc2idx(row2, col2)) def empty_per_idx(idx1, idx2): return 0 def empty_per_rc(row1, col1, row2, col2): return empty_per_idx(rc2idx(row1, col1), rc2idx(row2, col2)) def through_per_idx(idx1, idx2): if is_empty_idx(idx1, idx2): return (100-P)/100 if stop_cnt[idx1][idx2]==1 and randint(1, 100)<=P: return (100-P)/100 return (pow(P, stop_cnt[idx1][idx2])/pow(100, stop_cnt[idx1][idx2]-1)-P)/100 def through_per_rc(row1, col1, row2, col2): return through_per_idx(rc2idx(row1, col1), rc2idx(row2, col2)) def cmd_rc(row1, col1, row2, col2): if row1 > row2: return "U" if row1 < row2: return "D" if col1 > col2: return "L" if col1 < col2: return "R" def cmd_idx(idx1, idx2): r1, c1 = idx2rc(idx1) r2, c2 = idx2rc(idx2) return cmd_rc(r1, c1, r2, c2) for try_cnt in range(1, 1000+1): q = [(-1, 0, 0)] fixed = [[False]*W for _ in range(H)] dist = [[10]*W for _ in range(H)] prev = [[None]*W for _ in range(H)] while q: qper, qh, qw = pop(q) if fixed[qh][qw]: continue fixed[qh][qw] = True for a, b in sample(D, 4): h = qh+a; w = qw+b if not 0 <= h < H: continue if not 0 <= w < W: continue if fixed[h][w]: continue per = -(-qper*through_per_rc(qh, qw, h, w)) if dist[h][w] <= per: continue q.append((per, h, w)) prev[h][w] = (qh, qw) dist[h][w] = per node_idxs = [] h, w = H-1, W-1 while h+w: node_idxs.append(rc2idx(h, w)) h, w = prev[h][w] node_idxs.append(0) node_idxs.reverse() cmd = [] for i in range(len(node_idxs)-1): cmd.append(cmd_idx(node_idxs[i], node_idxs[i+1])) print(*cmd, sep="") through_cnt = int(input()) if through_cnt == -1: return for i in range(through_cnt): is_empty[node_idxs[i]][node_idxs[i+1]] = True is_empty[node_idxs[i+1]][node_idxs[i]] = True stop_cnt[node_idxs[through_cnt]][node_idxs[through_cnt+1]] += 1 stop_cnt[node_idxs[through_cnt+1]][node_idxs[through_cnt]] += 1 H, W, P = map(int, input().split()) solve(H, W, P)