結果
| 問題 |
No.2165 Let's Play Nim!
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-12-16 00:33:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 324 ms / 2,000 ms |
| コード長 | 954 bytes |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 82,496 KB |
| 実行使用メモリ | 94,948 KB |
| 平均クエリ数 | 863.56 |
| 最終ジャッジ日時 | 2024-11-14 16:45:24 |
| 合計ジャッジ時間 | 25,618 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 TLE * 6 |
ソースコード
#==================================================
def send(i,k):
print(i,k, flush=True)
def recieve():
i,k=map(int,input().split())
return i,k
def phase():
return int(input())
def choice(turn):
print(turn, flush=True)
#==================================================
def solve():
from collections import defaultdict
N=int(input())
A=[0]+list(map(int,input().split()))
grundy=0
for a in A[1:]:
grundy^=a
turn=1 if grundy else 0
choice(turn)
while True:
if turn:
msb=1<<(grundy.bit_length()-1)
for i in range(N+1):
if msb&A[i]==msb:
break
h=grundy^A[i]
k=A[i]-h
send(i,k)
else:
i,k=recieve()
grundy^=A[i]^(A[i]-k)
A[i]-=k
if phase()==-1:
return
turn^=1
#==================================================
solve()
Kazun