結果

問題 No.2165 Let's Play Nim!
コンテスト
ユーザー harurun
提出日時 2022-12-16 12:11:29
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 688 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 348 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 40,628 KB
平均クエリ数 12.10
最終ジャッジ日時 2026-05-10 14:54:29
合計ジャッジ時間 11,582 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 20 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
  N=int(input())
  A=list(map(int,input().split()))
  def f():
    t=0
    for i in A:
      t^=i
    c=0
    m=-1
    d=0
    while t>0:
      if (t&1):
        m=c
        d+=(1<<c)
      c+=1
      t>>=1
    for i in range(len(A)):
      if (A[i]>>m)&1 and A[i]>=d:
        A[i]-=d
        return [i+1,d]
  s=0
  for i in A:
    s^=i
  if s!=0:
    print(1,flush=True)
    print(*f(),flush=True)
    r=int(input())
    if r==-1:
      return
  else:
    print(0,flush=True)
  while 1:
    a,b=map(int,input().split())
    A[a-1]-=b
    r=int(input())
    if r==-1:
      return
    print(*f(),flush=True)
    r=int(input())
    if r==-1:
      return
  return

main()

    
0