結果
| 問題 |
No.3120 Lower Nim
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-23 16:22:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 564 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 284 ms |
| コンパイル使用メモリ | 82,596 KB |
| 実行使用メモリ | 97,976 KB |
| 平均クエリ数 | 2685.91 |
| 最終ジャッジ日時 | 2025-03-26 16:26:56 |
| 合計ジャッジ時間 | 17,794 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 43 |
ソースコード
from heapq import heappop,heappush
N=int(input())
A=list(map(int,input().split()))
X=0
pq=[]
for i in A:
X^=i
K=10**9
for i in range(N):
heappush(pq,(-A[i],i))
if X==0:
print("Second")
else:
K=X&-X
print("First")
v,i = heappop(pq)
print(i+1,K)
A[i]-=K
heappush(pq,(-A[i],i))
ret=int(input())
if ret!=0:
exit(0)
while 1:
i,x=map(int,input().split())
i-=1
A[i]-=x
heappush(pq,(-A[i],i))
ret=int(input())
if ret!=0:
exit(0)
K=x&-x
while 1:
v,i=heappop(pq)
if -A[i]==v:
break
print(i+1,K)
A[i]-=K
heappush(pq,(-A[i],i))
ret=int(input())
if ret!=0:
exit(0)