結果

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

テストケース

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

ソースコード

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
0