結果

問題 No.361 門松ゲーム2
ユーザー satama6satama6
提出日時 2022-10-19 02:05:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 1,283 ms
コンパイル使用メモリ 86,620 KB
実行使用メモリ 76,604 KB
最終ジャッジ日時 2023-09-11 17:28:09
合計ジャッジ時間 5,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,008 KB
testcase_01 AC 67 ms
71,124 KB
testcase_02 AC 68 ms
71,224 KB
testcase_03 AC 74 ms
71,180 KB
testcase_04 AC 69 ms
71,272 KB
testcase_05 AC 68 ms
71,288 KB
testcase_06 AC 70 ms
71,148 KB
testcase_07 AC 70 ms
71,400 KB
testcase_08 AC 80 ms
76,332 KB
testcase_09 AC 81 ms
76,152 KB
testcase_10 AC 78 ms
76,360 KB
testcase_11 AC 74 ms
76,304 KB
testcase_12 AC 79 ms
76,240 KB
testcase_13 AC 79 ms
76,604 KB
testcase_14 AC 118 ms
76,388 KB
testcase_15 AC 86 ms
76,336 KB
testcase_16 AC 128 ms
76,476 KB
testcase_17 AC 119 ms
76,544 KB
testcase_18 AC 88 ms
76,348 KB
testcase_19 AC 121 ms
76,456 KB
testcase_20 AC 85 ms
76,312 KB
testcase_21 AC 122 ms
76,480 KB
testcase_22 AC 145 ms
76,316 KB
testcase_23 AC 121 ms
76,412 KB
testcase_24 AC 128 ms
76,532 KB
testcase_25 AC 123 ms
76,404 KB
testcase_26 AC 129 ms
76,392 KB
testcase_27 AC 130 ms
76,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L, D = map(int, input().split())

# L1 < L2 < L3, L3 - L1 <= D, L1 + L2 + L3 = L

grundy = [0] * (L + 1)

for l in range(6, L+1):
    tmp = set()
    for l1 in range(1, l//3 + 1):
        for l2 in range(l1 + 1, l):
            l3 = l - l1 - l2
            if l3 <= l2:
                break
            if l3 - l1 > D:
                continue
            tmp.add(grundy[l1] ^ grundy[l2] ^ grundy[l3])
        
    g = 0
    while g in tmp:
        g += 1
    grundy[l] = g

if grundy[L] == 0:
    print('matsu')
else:
    print('kado')
0