結果
問題 |
No.715 集合と二人ゲーム
|
ユーザー |
![]() |
提出日時 | 2022-08-10 19:29:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 474 ms / 2,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 61,436 KB |
最終ジャッジ日時 | 2024-09-21 05:58:39 |
合計ジャッジ時間 | 19,496 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
from collections import defaultdict from functools import lru_cache import sys readline=sys.stdin.readline sys.setrecursionlimit(10**5) N=int(readline()) A=sorted(list(map(int,readline().split()))) bound=[0] for i in range(1,N): if A[i]-A[i-1]>=2: bound.append(i) bound.append(N) le=len(bound) grundy=[0]*1001 grundy[1]=1 for i in range(2,1000): dct=defaultdict(int) dct[grundy[i-2]]=2 for j in range(i-2): dct[grundy[j]^grundy[i-j-3]]+=1 g=0 while g in dct: g+=1 grundy[i]=g g=0 for i in range(le-1): x=bound[i+1]-bound[i] if x>=900: x-=900 x%=34 x+=900 g^=grundy[x] if g: ans="First" else: ans="Second" print(ans)