結果

問題 No.715 集合と二人ゲーム
コンテスト
ユーザー vwxyz
提出日時 2022-08-10 19:29:02
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 712 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 406 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 61,444 KB
最終ジャッジ日時 2026-04-09 13:12:38
合計ジャッジ時間 17,619 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0