結果
問題 |
No.715 集合と二人ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-03-31 15:00:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 488 ms / 2,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 112 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 59,680 KB |
最終ジャッジ日時 | 2024-06-24 16:36:27 |
合計ジャッジ時間 | 18,073 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache @lru_cache(None) def G(n): if n == 0: return 0 if n == 1: return 1 if n == 2: return 1 nums = [] nums.append(G(n - 2)) for k in range(3, n + 1): nums.append(G(k - 3) ^ G(n - k)) g = 0 nums = set(nums) while g in nums: g += 1 return g U = 1000 G = [G(n) for n in range(U)] """ from matplotlib import pyplot as plt plt.figure(figsize=(16,4)) plt.plot(range(300), A[:300]) """ N = int(readline()) A = sorted(map(int, read().split())) nums = [] prev = -10 n = 0 for x in A: if x == prev + 1: n += 1 else: nums.append(n) n = 1 prev = x nums.append(n) xor = 0 for n in nums: if n < U: xor ^= G[n] else: xor ^= G[n % 34 + 340] print('First' if xor else 'Second')