結果

問題 No.3120 Lower Nim
ユーザー titia
提出日時 2025-04-24 02:23:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 898 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 94,836 KB
平均クエリ数 2678.82
最終ジャッジ日時 2025-04-24 02:23:38
合計ジャッジ時間 22,588 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

flag=0
K=1<<63

if N==1:
    flag=1

for i in range(30):
    x=1<<i

    S=0

    for a in A:
        S+=a//x

    if S%2==1:
        flag=1

if flag:
    print("First",flush=True)
else:
    print("Second",flush=True)

    i,x=map(int,input().split())
    ret=int(input())

    if ret==-1:
        exit()
        
    A[i-1]-=x
    K=min(K,x)

LIST=set()
for i in range(N):
    if A[i]!=0:
        LIST.add(i)

while True:
    if len(LIST)==1 and K==1<<63:
        ind=LIST.pop()

        print(ind+1,A[ind],flush=True)
        ret=int(input())
        if ret!=0:
            exit()

    for i in range(1<<30):
        x=1<<i

        S=0

        for ind in LIST:
            S+=A[ind]//x

        if S%2==1:
            tx=x
            break

    tind=-1
    for ind in LIST:
        if A[ind]>=tx:
            tind=ind
            break


    print(tind+1,tx,flush=True)
    ret=int(input())
    if ret!=0:
        exit()
    A[tind]-=tx
    if A[tind]==0:
        LIST.remove(tind)
    K=min(K,tx)

    i,x=map(int,input().split())
    ret=int(input())

    if ret==-1:
        exit()
        
    A[i-1]-=x
    if A[i-1]==0:
        LIST.remove(i-1)
    K=min(K,x)
    
    

        
        
    
        
    
0