結果

問題 No.331 CodeRunnerでやれ
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 00:15:24
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 6,732 KB
実行使用メモリ 24,420 KB
平均クエリ数 499.94
最終ジャッジ日時 2023-09-23 11:44:01
合計ジャッジ時間 6,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
23,560 KB
testcase_01 RE -
testcase_02 AC 172 ms
24,048 KB
testcase_03 RE -
testcase_04 AC 158 ms
23,544 KB
testcase_05 RE -
testcase_06 AC 373 ms
24,072 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 279 ms
23,400 KB
testcase_11 AC 274 ms
24,076 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(100000)

def communicate(S):
    print S
    sys.stdout.flush()
    T = raw_input()
    return int(T) if T.isdigit() else T

def goal():
    print 'F'
    sys.stdout.flush()
    S = raw_input()
    while S != "Merry Christmas!":
        print 'F'
        sys.stdout.flush()
        S = raw_input()
    exit()

MAX = 20151224
visited = set()
dxdy = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d = 0

def dfs(x, y, d, n):
    if n == MAX:
        goal()
    visited.add((x, y))
    if n > 0:
        dfs(x+dxdy[d][0], y+dxdy[d][1], d, communicate('F'))
    n = communicate('R')
    d = (d+1)%4
    if n > 0 and (x+dxdy[d][0], y+dxdy[d][1]) not in visited:
        dfs(x+dxdy[d][0], y+dxdy[d][1], d, communicate('F'))
    communicate('R')
    n = communicate('R')
    d = (d+2)%4
    if n > 0 and (x+dxdy[d][0], y+dxdy[d][1]) not in visited:
        dfs(x+dxdy[d][0], y+dxdy[d][1], d, communicate('F'))
    communicate('R')
    d = (d+1)%4
    communicate('B')
    return

dfs(0, 0, 0, int(raw_input()))
communicate('F')
communicate('R')
n = communicate('R')
dfs(0, 0, 2, n)
0