結果

問題 No.361 門松ゲーム2
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-05-15 19:25:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,602 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-15 21:54:30
合計ジャッジ時間 12,608 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 34 ms
10,752 KB
testcase_09 AC 33 ms
11,008 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 AC 34 ms
10,880 KB
testcase_13 AC 34 ms
10,752 KB
testcase_14 AC 798 ms
10,880 KB
testcase_15 AC 88 ms
10,880 KB
testcase_16 AC 971 ms
10,880 KB
testcase_17 AC 785 ms
10,880 KB
testcase_18 AC 130 ms
10,880 KB
testcase_19 AC 799 ms
10,880 KB
testcase_20 AC 67 ms
10,880 KB
testcase_21 AC 876 ms
10,880 KB
testcase_22 AC 1,602 ms
10,880 KB
testcase_23 AC 983 ms
10,752 KB
testcase_24 AC 979 ms
10,880 KB
testcase_25 AC 986 ms
10,880 KB
testcase_26 AC 1,043 ms
10,752 KB
testcase_27 AC 1,052 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

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