結果

問題 No.2655 Increasing Strides
ユーザー eloyeloy
提出日時 2024-03-01 22:45:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,062 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 157,780 KB
最終ジャッジ日時 2024-03-01 22:45:24
合計ジャッジ時間 5,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,604 KB
testcase_01 AC 38 ms
55,604 KB
testcase_02 AC 37 ms
55,604 KB
testcase_03 AC 37 ms
55,604 KB
testcase_04 AC 48 ms
55,604 KB
testcase_05 AC 42 ms
55,604 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
60,940 KB
testcase_09 AC 43 ms
60,940 KB
testcase_10 AC 52 ms
65,964 KB
testcase_11 AC 68 ms
74,320 KB
testcase_12 AC 76 ms
76,152 KB
testcase_13 AC 96 ms
76,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 793 ms
87,952 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

def increasing_strides(max):
    cache = defaultdict(bool)

    def worker(x, y, i, dir):
        if x == 0 and y == 0:
            return True
        elif i == max:
            return False
        elif cache.get((x, y, i, dir)):
            return cache[(x, y, i, dir)]
        else:
            if dir == 0 or dir == 180:
                cache[(x + i, y, i+1, 270)] = worker(x + i, y, i+1, 270)
                cache[(x - i, y, i+1, 90)] = worker(x - i, y, i+1, 90)
            elif dir == 90 or dir == 270:
                cache[(x, y + i, i+1, 0)] = worker(x, y+i, i+1, 0)
                cache[(x, y - i, i+1, 180)] = worker(x, y-i, i+1, 180)

    worker(0, 1, 1, 0)

n = inp()
print("Yes" if increasing_strides(n) else "No")
0