結果

問題 No.331 CodeRunnerでやれ
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-05-15 16:08:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,105 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 99,568 KB
最終ジャッジ日時 2023-09-23 23:51:51
合計ジャッジ時間 14,296 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import array
import collections
import sys


MAX_SIZE = 20
RES_GOAL = "Merry Christmas!"
DIST_INF = 20151224
DRS = [1, 0, -1, 0]
DCS = [0, 1, 0, -1]


class Solver(object):

    def __init__(self):
        self.visited = collections.defaultdict(bool)

    def depth_first_search(self, r0, c0, angle):
        self.visited[(r0, c0)] = True
        for _ in range(4):
            result = self.submit("R")
            while result >= DIST_INF:
                self.submit("F")
            new_angle = (angle + 1) % 4
            r = r0 + DRS[new_angle]
            c = c0 + DCS[new_angle]
            if result > 0 and not self.visited[(r, c)]:
                self.submit("F")
                self.depth_first_search(r, c, new_angle)
        self.submit("B")

    @staticmethod
    def submit(command):
        print(command)
        sys.stdout.flush()
        result = input()
        if result == RES_GOAL:
            sys.exit()
        else:
            return int(result)


def main():
    s = Solver()
    s.depth_first_search(0, 0, 0)


if __name__ == '__main__':
    main()
0