結果
問題 |
No.3258 Xor Division Game
|
ユーザー |
|
提出日時 | 2025-09-05 19:51:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,642 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 307,676 KB |
最終ジャッジ日時 | 2025-09-05 21:18:09 |
合計ジャッジ時間 | 51,427 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 67 |
ソースコード
# 再帰、Dict import sys from collections import defaultdict from bisect import bisect_left sys.setrecursionlimit(10**6) n = int(input()) f = list(map(int, input().split())) c = defaultdict(list) for i, x in enumerate(f): c[x].append(i) def cnt(x, l, r): return bisect_left(c[x], r) - bisect_left(c[x], l) def calc(l, r): d = r - l nl = l nr = r - 1 m = -1 while nl <= nr: if cnt(f[nl], l, r) == 1: m = nl break if cnt(f[nr], l, r) == 1: m = nr break nl += 1 nr -= 1 if m == -1: return 0 return calc(l, m) ^ calc(m+1, r) ^ 1 print("Alice" if calc(0, n) else "Bob")