結果

問題 No.361 門松ゲーム2
ユーザー tcltktcltk
提出日時 2021-06-06 07:14:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 404 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 84,288 KB
最終ジャッジ日時 2023-08-14 13:51:54
合計ジャッジ時間 8,536 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
80,776 KB
testcase_01 AC 200 ms
80,696 KB
testcase_02 AC 201 ms
81,028 KB
testcase_03 AC 197 ms
80,692 KB
testcase_04 AC 198 ms
80,980 KB
testcase_05 AC 200 ms
81,096 KB
testcase_06 AC 201 ms
80,928 KB
testcase_07 AC 198 ms
80,940 KB
testcase_08 AC 211 ms
83,764 KB
testcase_09 AC 211 ms
83,708 KB
testcase_10 AC 201 ms
81,776 KB
testcase_11 AC 205 ms
83,460 KB
testcase_12 AC 210 ms
83,688 KB
testcase_13 AC 218 ms
84,004 KB
testcase_14 AC 284 ms
84,128 KB
testcase_15 AC 217 ms
84,112 KB
testcase_16 AC 241 ms
84,080 KB
testcase_17 AC 227 ms
83,796 KB
testcase_18 AC 222 ms
84,080 KB
testcase_19 AC 226 ms
84,000 KB
testcase_20 AC 219 ms
83,816 KB
testcase_21 AC 241 ms
84,236 KB
testcase_22 AC 404 ms
84,288 KB
testcase_23 AC 214 ms
83,928 KB
testcase_24 AC 213 ms
83,792 KB
testcase_25 AC 217 ms
84,104 KB
testcase_26 AC 227 ms
84,068 KB
testcase_27 AC 225 ms
83,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

def get_grundy(L):
    if L < 6:
        return 0
    if L in Memo:
        return Memo[L]
    
    s = set()
    for a in range(1, L//3-1 + 1):
        for b in range(a+1, (L-a-1)//2 + 1):
            c = L - a - b
            if c - a <= D:
                s.add(get_grundy(a) ^ get_grundy(b) ^ get_grundy(c))
    mex = 0
    while mex in s:
        mex += 1
    Memo[L] = mex
    return mex

Memo = collections.defaultdict(int)
L, D = map(int, input().split())
g = get_grundy(L)
if g == 0:
    print('matsu')
else:
    print('kado')
0