結果

問題 No.331 CodeRunnerでやれ
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 00:19:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 408 ms / 5,000 ms
コード長 1,135 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 6,708 KB
実行使用メモリ 24,324 KB
平均クエリ数 409.06
最終ジャッジ日時 2023-09-24 00:40:17
合計ジャッジ時間 6,596 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
23,788 KB
testcase_01 AC 155 ms
23,968 KB
testcase_02 AC 163 ms
23,808 KB
testcase_03 AC 217 ms
23,784 KB
testcase_04 AC 164 ms
23,592 KB
testcase_05 AC 162 ms
24,312 KB
testcase_06 AC 353 ms
24,192 KB
testcase_07 AC 184 ms
23,928 KB
testcase_08 AC 408 ms
24,324 KB
testcase_09 AC 186 ms
23,604 KB
testcase_10 AC 269 ms
23,484 KB
testcase_11 AC 265 ms
23,980 KB
testcase_12 AC 231 ms
23,796 KB
testcase_13 AC 250 ms
23,484 KB
testcase_14 AC 273 ms
24,312 KB
testcase_15 AC 230 ms
23,580 KB
testcase_16 AC 331 ms
23,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10000)

def communicate(S):
    print S
    sys.stdout.flush()
    T = raw_input()
    if T == '20151224':
        goal()
    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