結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
23,680 KB
testcase_01 RE -
testcase_02 AC 176 ms
23,412 KB
testcase_03 RE -
testcase_04 AC 163 ms
24,060 KB
testcase_05 RE -
testcase_06 AC 380 ms
24,072 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 264 ms
23,424 KB
testcase_11 AC 267 ms
23,544 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10000)

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