結果

問題 No.361 門松ゲーム2
ユーザー ayaoniayaoni
提出日時 2021-05-02 19:22:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 302 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 1,046 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 78,632 KB
最終ジャッジ日時 2023-09-28 09:49:10
合計ジャッジ時間 6,688 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
72,456 KB
testcase_01 AC 106 ms
72,376 KB
testcase_02 AC 104 ms
72,556 KB
testcase_03 AC 106 ms
72,392 KB
testcase_04 AC 107 ms
72,544 KB
testcase_05 AC 105 ms
72,400 KB
testcase_06 AC 106 ms
72,352 KB
testcase_07 AC 106 ms
72,392 KB
testcase_08 AC 121 ms
77,268 KB
testcase_09 AC 118 ms
77,396 KB
testcase_10 AC 115 ms
77,028 KB
testcase_11 AC 115 ms
77,172 KB
testcase_12 AC 118 ms
77,596 KB
testcase_13 AC 118 ms
77,536 KB
testcase_14 AC 189 ms
78,108 KB
testcase_15 AC 121 ms
77,520 KB
testcase_16 AC 145 ms
78,228 KB
testcase_17 AC 129 ms
77,768 KB
testcase_18 AC 123 ms
77,868 KB
testcase_19 AC 128 ms
77,664 KB
testcase_20 AC 124 ms
77,772 KB
testcase_21 AC 148 ms
78,152 KB
testcase_22 AC 302 ms
78,632 KB
testcase_23 AC 117 ms
77,636 KB
testcase_24 AC 121 ms
77,576 KB
testcase_25 AC 120 ms
77,748 KB
testcase_26 AC 130 ms
77,716 KB
testcase_27 AC 133 ms
77,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


L,D = MI()


@lru_cache(maxsize=None)
def Grundy(x):
    if x <= 5:
        return 0

    G = set()
    for i in range(1,x//3):
        for j in range(i+1,x):
            k = x-i-j
            if k <= j:
                break
            if k-i > D:
                continue
            g = Grundy(i) ^ Grundy(j) ^ Grundy(k)
            G.add(g)

    for i in range(10**6):
        if not (i in G):
            return i


g = Grundy(L)
if g:
    print('kado')
else:
    print('matsu')
0