結果

問題 No.3120 Lower Nim
ユーザー keymoon
提出日時 2025-04-19 23:18:06
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,446 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 82,620 KB
実行使用メモリ 94,516 KB
平均クエリ数 2130.41
最終ジャッジ日時 2025-04-19 23:18:20
合計ジャッジ時間 12,318 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35 WA * 6 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from operator import xor


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

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

if INIT_XOR_ALL != 0:
    print("First", flush=True)
    my_turn = True
else:
    # こっちはOK firstがなんかバグってる?
    print("Second", flush=True)
    my_turn = False

if INIT_XOR_ALL == 1:
    exit(1)
    remain = list(range(len(A)))
    def proceed(i, x):
        A[i] -= x
        if A[i] == 0:
            remain.remove(i)
        if int(input().strip()) != 0: exit(0)
    
    while True:
        print(remain[0]+1, 1, flush=True)
        proceed(remain[0], 1)
        j, x = map(int, input().split())
        proceed(j-1, x)
    

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

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

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

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

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