結果

問題 No.361 門松ゲーム2
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-05-15 19:27:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,944 KB
実行使用メモリ 76,480 KB
最終ジャッジ日時 2024-04-15 21:54:35
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,608 KB
testcase_01 AC 43 ms
52,352 KB
testcase_02 AC 42 ms
52,224 KB
testcase_03 AC 44 ms
52,736 KB
testcase_04 AC 43 ms
52,992 KB
testcase_05 AC 42 ms
52,608 KB
testcase_06 AC 45 ms
52,992 KB
testcase_07 AC 41 ms
52,608 KB
testcase_08 AC 54 ms
62,976 KB
testcase_09 AC 57 ms
64,512 KB
testcase_10 AC 54 ms
63,360 KB
testcase_11 AC 53 ms
61,568 KB
testcase_12 AC 55 ms
63,744 KB
testcase_13 AC 57 ms
63,232 KB
testcase_14 AC 163 ms
76,288 KB
testcase_15 AC 73 ms
76,292 KB
testcase_16 AC 192 ms
76,424 KB
testcase_17 AC 171 ms
75,968 KB
testcase_18 AC 83 ms
76,032 KB
testcase_19 AC 184 ms
76,224 KB
testcase_20 AC 66 ms
70,272 KB
testcase_21 AC 175 ms
76,480 KB
testcase_22 AC 240 ms
76,024 KB
testcase_23 AC 177 ms
76,160 KB
testcase_24 AC 197 ms
76,092 KB
testcase_25 AC 196 ms
76,432 KB
testcase_26 AC 203 ms
76,288 KB
testcase_27 AC 210 ms
76,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import array


def mex(s):
    m = 0
    while m in s:
        m += 1
    return m


def can_kado_win(l, d):
    gs = array.array("I", (0 for _ in range(l + 1)))
    for i in range(1, l + 1):
        next_gs = set()
        for l1 in range(3, i - 2):
            for l2 in range(2, i - l1):
                if l1 <= l2:
                    continue
                l3 = i - l1 - l2
                if l2 <= l3:
                    continue
                if l1 - l3 <= d:
                    next_gs.add(gs[l1] ^ gs[l2] ^ gs[l3])
        gs[i] = mex(next_gs)
    return gs[l] != 0


def main():
    l, d = map(int, input().split())
    print("kado" if can_kado_win(l, d) else "matsu")


if __name__ == '__main__':
    main()
0