結果

問題 No.3120 Lower Nim
ユーザー keymoon
提出日時 2025-04-19 22:37:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 90,020 KB
平均クエリ数 1.00
最終ジャッジ日時 2025-04-19 22:38:08
合計ジャッジ時間 10,050 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# written by ChatGPT o4-mini-high (really sorry)
import random

N = int(input().strip())
A = list(map(int, input().split()))
K = 10**9

xor_all = 0
for a in A:
    xor_all ^= a

if xor_all != 0:
    print("First", flush=True)
    my_turn = True
else:
    print("Second", flush=True)
    my_turn = False

while True:
    if my_turn:
        xor_all = 0
        for a in A:
            xor_all ^= a

		
        for i, a in enumerate(A)[::-1]:
            t = a ^ xor_all
            if t < a:
                x = a - t
                if x <= K:
                    idx = i
                    break
        else:
            for i, a in enumerate(A):
                if 1 <= a <= K:
                    x = a
                    idx = i
                    break

        A[idx] -= x
        K = x
        print(idx+1, x, flush=True)

        ret = int(input().strip())
        if ret != 0:
            exit(0)
        my_turn = False

    else:
        line = input().split()
        if not line:
            exit(0)
        j, x = map(int, line)
        ret = int(input().strip())
        A[j-1] -= x
        K = x
        if ret == -1:
            exit(0)
        my_turn = True
0