結果

問題 No.361 門松ゲーム2
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-17 15:21:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 913 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,136 KB
最終ジャッジ日時 2023-12-23 14:19:07
合計ジャッジ時間 5,184 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 42 ms
59,836 KB
testcase_08 AC 88 ms
75,924 KB
testcase_09 AC 86 ms
75,900 KB
testcase_10 AC 69 ms
73,624 KB
testcase_11 AC 56 ms
68,312 KB
testcase_12 AC 64 ms
72,596 KB
testcase_13 AC 80 ms
75,668 KB
testcase_14 AC 374 ms
75,892 KB
testcase_15 AC 94 ms
75,924 KB
testcase_16 AC 202 ms
76,052 KB
testcase_17 AC 134 ms
75,924 KB
testcase_18 AC 107 ms
75,924 KB
testcase_19 AC 120 ms
75,924 KB
testcase_20 AC 92 ms
75,924 KB
testcase_21 AC 205 ms
76,052 KB
testcase_22 AC 913 ms
76,136 KB
testcase_23 AC 97 ms
76,036 KB
testcase_24 AC 97 ms
75,800 KB
testcase_25 AC 105 ms
75,796 KB
testcase_26 AC 145 ms
76,036 KB
testcase_27 AC 160 ms
75,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l, d = map(int, input().split())

N = 550
grundy = [-1]*N
grundy[1] = 0
grundy[2] = 0
def rec(x):
    if grundy[x] != -1:
        return grundy[x]
    S = set()
    for l1 in range(1, x-1):
        for l2 in range(1, x-1):
            l3 = x-l1-l2
            if l3 <= 0:
                continue
            if l1 == l2 or l2 == l3 or l3 == l1:
                continue
            if max(l1, l2, l3)-min(l1, l2, l3) <= d:
                g = rec(l1)^rec(l2)^rec(l3)
                S.add(g)
    g = 0
    while True:
        if g not in S:
            break
        else:
            g += 1
    grundy[x] = g
    return g

g = rec(l)
if g == 0:
    print('matsu')
else:
    print('kado')
0