結果

問題 No.2165 Let's Play Nim!
ユーザー mkawa2
提出日時 2022-12-19 00:19:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 592 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 101,144 KB
平均クエリ数 1.85
最終ジャッジ日時 2024-11-18 00:07:16
合計ジャッジ時間 34,747 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1
other AC * 1 RE * 29 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

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

hp = []
x = 0
for i, a in enumerate(aa):
    x ^= a
    heappush(hp, (-a, i))

t = 1 if x else 0
print(t, flush=True)

ret = 0
while ret == 0:
    if t:
        i = a = -1
        while aa[i] != a:
            a, i = heappop(hp)
            a = -a
        b = x ^ a
        k = a-b
        print(i+1, k, flush=True)
        aa[i] = b
    else:
        i, k = map(int, input().split())
        i -= 1
        a = aa[i]
        b = a-k
        x ^= a ^ b
    if b: heappush(hp, (-b, i))
    ret = int(input())
        
0