結果

問題 No.3258 Xor Division Game
ユーザー lif4635
提出日時 2025-09-05 20:31:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 185,332 KB
最終ジャッジ日時 2025-09-05 21:18:25
合計ジャッジ時間 14,605 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 48 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

# stack、座圧
import sys
from random import randrange
from collections import defaultdict 
from bisect import bisect_left
sys.setrecursionlimit(10 ** 6)

n = int(input())
f = list(map(int, input().split()))

idx = {x:i for i, x in enumerate(set(f))}

f = [idx[x] for x in f]
c = [[] for i in range(n)]
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)

ans = 0
st = [(0, n)]
while st:
    l, r = st.pop()
    d = r - l
    m = -1
    use = set()
    while len(use) == d:
        x = randrange(0, d)
        while x in use:
            x = (x + 1) % d
        m = x + l
        if cnt(f[m], l, r) == 1:
            break
        else:
            use.add(x)
        
    if m != -1:
        ans ^= 1
        st.append((l, m))
        st.append((m+1, r))

print("Alice" if ans else "Bob")
0