結果
問題 | No.5006 Hidden Maze |
ユーザー | kys |
提出日時 | 2022-06-12 15:29:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 689 ms / 2,000 ms |
コード長 | 2,456 bytes |
コンパイル時間 | 610 ms |
実行使用メモリ | 102,240 KB |
スコア | 0 |
平均クエリ数 | 1000.00 |
最終ジャッジ日時 | 2022-06-12 15:31:12 |
合計ジャッジ時間 | 62,463 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 562 ms
100,732 KB |
testcase_01 | AC | 566 ms
100,400 KB |
testcase_02 | AC | 600 ms
101,632 KB |
testcase_03 | AC | 529 ms
100,780 KB |
testcase_04 | AC | 598 ms
100,856 KB |
testcase_05 | AC | 552 ms
100,748 KB |
testcase_06 | AC | 545 ms
99,868 KB |
testcase_07 | AC | 552 ms
100,012 KB |
testcase_08 | AC | 541 ms
100,752 KB |
testcase_09 | AC | 542 ms
100,144 KB |
testcase_10 | AC | 547 ms
101,352 KB |
testcase_11 | AC | 551 ms
100,524 KB |
testcase_12 | AC | 554 ms
100,396 KB |
testcase_13 | AC | 598 ms
100,776 KB |
testcase_14 | AC | 530 ms
100,528 KB |
testcase_15 | AC | 532 ms
100,472 KB |
testcase_16 | AC | 620 ms
101,056 KB |
testcase_17 | AC | 543 ms
101,356 KB |
testcase_18 | AC | 587 ms
99,836 KB |
testcase_19 | AC | 570 ms
100,692 KB |
testcase_20 | AC | 549 ms
101,292 KB |
testcase_21 | AC | 540 ms
101,108 KB |
testcase_22 | AC | 567 ms
100,488 KB |
testcase_23 | AC | 565 ms
101,068 KB |
testcase_24 | AC | 593 ms
101,476 KB |
testcase_25 | AC | 535 ms
101,756 KB |
testcase_26 | AC | 511 ms
100,396 KB |
testcase_27 | AC | 563 ms
101,124 KB |
testcase_28 | AC | 548 ms
101,416 KB |
testcase_29 | AC | 541 ms
100,156 KB |
testcase_30 | AC | 632 ms
101,512 KB |
testcase_31 | AC | 536 ms
101,272 KB |
testcase_32 | AC | 524 ms
100,504 KB |
testcase_33 | AC | 555 ms
100,500 KB |
testcase_34 | AC | 518 ms
100,564 KB |
testcase_35 | AC | 564 ms
100,788 KB |
testcase_36 | AC | 567 ms
99,716 KB |
testcase_37 | AC | 530 ms
100,344 KB |
testcase_38 | AC | 523 ms
100,600 KB |
testcase_39 | AC | 590 ms
101,244 KB |
testcase_40 | AC | 557 ms
101,328 KB |
testcase_41 | AC | 606 ms
102,148 KB |
testcase_42 | AC | 615 ms
100,732 KB |
testcase_43 | AC | 533 ms
100,592 KB |
testcase_44 | AC | 535 ms
100,628 KB |
testcase_45 | AC | 566 ms
101,040 KB |
testcase_46 | AC | 530 ms
100,508 KB |
testcase_47 | AC | 558 ms
99,944 KB |
testcase_48 | AC | 587 ms
101,060 KB |
testcase_49 | AC | 570 ms
100,680 KB |
testcase_50 | AC | 555 ms
100,176 KB |
testcase_51 | AC | 534 ms
100,616 KB |
testcase_52 | AC | 617 ms
101,848 KB |
testcase_53 | AC | 689 ms
101,348 KB |
testcase_54 | AC | 543 ms
100,872 KB |
testcase_55 | AC | 602 ms
101,496 KB |
testcase_56 | AC | 593 ms
102,012 KB |
testcase_57 | AC | 574 ms
101,804 KB |
testcase_58 | AC | 555 ms
100,260 KB |
testcase_59 | AC | 643 ms
102,080 KB |
testcase_60 | AC | 524 ms
99,796 KB |
testcase_61 | AC | 581 ms
100,932 KB |
testcase_62 | AC | 534 ms
100,572 KB |
testcase_63 | AC | 592 ms
101,460 KB |
testcase_64 | AC | 615 ms
100,688 KB |
testcase_65 | AC | 581 ms
100,828 KB |
testcase_66 | AC | 561 ms
99,960 KB |
testcase_67 | AC | 592 ms
100,912 KB |
testcase_68 | AC | 555 ms
100,484 KB |
testcase_69 | AC | 592 ms
100,836 KB |
testcase_70 | AC | 582 ms
100,524 KB |
testcase_71 | AC | 560 ms
99,852 KB |
testcase_72 | AC | 605 ms
102,240 KB |
testcase_73 | AC | 615 ms
100,956 KB |
testcase_74 | AC | 554 ms
100,140 KB |
testcase_75 | AC | 552 ms
100,724 KB |
testcase_76 | AC | 601 ms
101,024 KB |
testcase_77 | AC | 551 ms
100,204 KB |
testcase_78 | AC | 535 ms
100,456 KB |
testcase_79 | AC | 525 ms
99,848 KB |
testcase_80 | AC | 567 ms
100,500 KB |
testcase_81 | AC | 618 ms
100,704 KB |
testcase_82 | AC | 614 ms
100,460 KB |
testcase_83 | AC | 626 ms
100,260 KB |
testcase_84 | AC | 547 ms
100,500 KB |
testcase_85 | AC | 596 ms
101,496 KB |
testcase_86 | AC | 606 ms
100,872 KB |
testcase_87 | AC | 570 ms
101,716 KB |
testcase_88 | AC | 594 ms
101,124 KB |
testcase_89 | AC | 560 ms
100,908 KB |
testcase_90 | AC | 570 ms
100,344 KB |
testcase_91 | AC | 573 ms
100,808 KB |
testcase_92 | AC | 530 ms
99,900 KB |
testcase_93 | AC | 578 ms
100,944 KB |
testcase_94 | AC | 592 ms
100,708 KB |
testcase_95 | AC | 611 ms
101,136 KB |
testcase_96 | AC | 573 ms
99,760 KB |
testcase_97 | AC | 599 ms
100,888 KB |
testcase_98 | AC | 537 ms
100,884 KB |
testcase_99 | AC | 602 ms
101,068 KB |
ソースコード
import sys input = sys.stdin.readline def iinput(): return int(input()) def sinput(): return input().rstrip() def i0input(): return int(input()) - 1 def linput(): return list(input().split()) def liinput(): return list(map(int, input().split())) def miinput(): return map(int, input().split()) def li0input(): return list(map(lambda x: int(x) - 1, input().split())) def mi0input(): return map(lambda x: int(x) - 1, input().split()) INF = 10**20 MOD = 1000000007 from random import random, seed seed(101010) def random_direction(p): for i in range(3): p[i+1] += p[i] r = random() for i in range(4): if p[i] > r: return i H, W, p = liinput() # URDL probability = [[[0.75] * W for _ in [0] * H] for _ in [0] * 4] p /= 100 direction_inv = {'U': 0, 'R': 1, 'D': 2, 'L': 3} direction = 'URDL' direction_coord = [(-1, 0), (0, 1), (1, 0), (0, -1)] for i in range(W): probability[0][0][i] = 0 probability[2][-1][i] = 0 for i in range(H): probability[1][i][-1] = 0 probability[3][i][0] = 0 for _ in [0] * 1000: place = [0, 0] res = [] for _ in [0] * 400: prob_tmp = [] for i in range(4): try: prob_tmp.append(probability[i][place[0]][place[1]]) except IndexError: print('IndexError', place) sum_prob = sum(prob_tmp) for i in range(4): prob_tmp[i] /= sum_prob d = random_direction(prob_tmp) dr, dc = direction_coord[d] place[0] += dr place[1] += dc res.append(direction[d]) print(''.join(res), flush=True) thr = iinput() if thr == -1: exit() place = [0, 0] for i in range(thr): if place == [H-1, W-1]: print(''.join(res)[:i+1], flush=True) g = iinput() if g == -1: exit() d = direction_inv[res[i]] probability[d][place[0]][place[1]] = 1 dr, dc = direction_coord[d] place[0] += dr place[1] += dc probability[(d+2)%4][place[0]][place[1]] = 1 if len(res) > thr: d = direction_inv[res[thr]] q = probability[d][place[0]][place[1]] if q < 1: new_p = (p * q) / (p * q + 1 - q) probability[d][place[0]][place[1]] = new_p dr, dc = direction_coord[d] place[0] += dr place[1] += dc probability[(d+2)%4][place[0]][place[1]] = new_p