結果
| 問題 |
No.361 門松ゲーム2
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2021-05-02 19:22:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 274 ms / 2,000 ms |
| コード長 | 968 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 77,056 KB |
| 最終ジャッジ日時 | 2024-07-21 04:27:46 |
| 合計ジャッジ時間 | 3,667 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
L,D = MI()
@lru_cache(maxsize=None)
def Grundy(x):
if x <= 5:
return 0
G = set()
for i in range(1,x//3):
for j in range(i+1,x):
k = x-i-j
if k <= j:
break
if k-i > D:
continue
g = Grundy(i) ^ Grundy(j) ^ Grundy(k)
G.add(g)
for i in range(10**6):
if not (i in G):
return i
g = Grundy(L)
if g:
print('kado')
else:
print('matsu')
ayaoni