結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
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 = 2015122420151224
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))
    print 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