結果

問題 No.2165 Let's Play Nim!
ユーザー titia
提出日時 2022-12-16 01:32:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 864 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 88,584 KB
平均クエリ数 3.10
最終ジャッジ日時 2024-11-14 17:53:36
合計ジャッジ時間 7,084 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 RE * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush
from operator import itemgetter

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

XOR=0
for a in A:
    XOR^=a

if XOR==0:
    print(0,flush=True)

    i,k=map(int,input().split())
    XOR^=A[i-1]
    A[i-1]-=k
    XOR^=A[i-1]
    ret=int(input())
    if ret==-1:
        exit()
else:
    print(1,flush=True)

H=[]

for i in range(n):
    H.append((-A[i],i))
H.sort(key=itemgetter(0))

while H:
    k,ind=heappop(H)
    if A[ind]!=-k:
        continue

    k=-k
    nec=XOR^k
    print(ind+1,k-nec,flush=True)
    ret=int(input())
    if ret==-1:
        exit()
    A[ind]=nec
    XOR=0

    if nec!=0:
        heappush(H,(-nec,ind))

    i,k=map(int,input().split())
    XOR^=A[i-1]
    A[i-1]-=k
    XOR^=A[i-1]
    if A[i-1]!=0:
        heappush(H,(-A[i-1],i-1))
    ret=int(input())
    if ret==-1:
        exit()

    
    
0