結果

問題 No.2165 Let's Play Nim!
ユーザー roaris
提出日時 2022-12-16 02:05:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 82,572 KB
実行使用メモリ 93,344 KB
平均クエリ数 863.56
最終ジャッジ日時 2024-11-14 18:55:15
合計ジャッジ時間 24,630 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
x = 0

for ai in a:
    x ^= ai

t = 1 if x!=0 else 0
print(t)
sys.stdout.flush()
turn = 0

while True:
    if turn^t:
        for i in range(n):
            if a[i]>x^a[i]:
                k = a[i]-(x^a[i])
                print(i+1, k)
                sys.stdout.flush()
                x ^= a[i]
                a[i] -= k
                x ^= a[i]
                break
    else:
        i, k = map(int, input().split())
        x ^= a[i-1]
        a[i-1] -= k
        x ^= a[i-1]
    
    ret = int(input())
    
    if ret==-1:
        exit()
    
    turn ^= 1
0