結果

問題 No.2165 Let's Play Nim!
ユーザー ntudantuda
提出日時 2023-04-15 23:44:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,086 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 117,268 KB
平均クエリ数 812.51
最終ジャッジ日時 2024-04-19 15:37:34
合計ジャッジ時間 34,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
68,704 KB
testcase_01 AC 1,030 ms
104,112 KB
testcase_02 AC 1,116 ms
105,028 KB
testcase_03 AC 587 ms
97,128 KB
testcase_04 AC 59 ms
70,472 KB
testcase_05 AC 123 ms
92,964 KB
testcase_06 AC 123 ms
93,256 KB
testcase_07 AC 105 ms
92,140 KB
testcase_08 AC 649 ms
98,688 KB
testcase_09 AC 65 ms
77,520 KB
testcase_10 AC 150 ms
93,096 KB
testcase_11 AC 1,165 ms
104,668 KB
testcase_12 AC 951 ms
101,436 KB
testcase_13 AC 58 ms
70,472 KB
testcase_14 AC 116 ms
92,988 KB
testcase_15 AC 63 ms
71,352 KB
testcase_16 AC 847 ms
100,000 KB
testcase_17 AC 355 ms
95,336 KB
testcase_18 TLE -
testcase_19 AC 58 ms
70,324 KB
testcase_20 AC 97 ms
90,448 KB
testcase_21 AC 277 ms
95,024 KB
testcase_22 AC 216 ms
95,056 KB
testcase_23 AC 194 ms
94,048 KB
testcase_24 AC 186 ms
93,928 KB
testcase_25 AC 491 ms
95,476 KB
testcase_26 AC 1,096 ms
102,716 KB
testcase_27 AC 229 ms
94,480 KB
testcase_28 AC 384 ms
95,084 KB
testcase_29 AC 56 ms
69,728 KB
testcase_30 AC 55 ms
69,808 KB
testcase_31 AC 55 ms
69,088 KB
testcase_32 AC 225 ms
94,916 KB
evil_2_big_1.txt TLE -
evil_2_big_2.txt TLE -
evil_2_big_3.txt TLE -
evil_big_1.txt TLE -
evil_big_2.txt TLE -
evil_big_3.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *


def rec():
    ret = int(input())
    if ret == -1:
        exit()

def out():
    global g
    maxa = max(A)
    g2 = g ^ maxa
    if maxa <= g2:
        i = A.index(max)
        print(i + 1, g2)
    else:
        g2 = g ^ maxa
        for i in range(n):
            if A[i] >= g2:
                break
        g ^= A[i]
        A[i] = g
        g ^= g

def inp():
    global g
    i, k = map(int, input().split())
    g ^= A[i - 1]
    A[i - 1] -= k
    g ^= A[i - 1]


n = int(input())
A = list(map(int, input().split()))
g = 0
q = []
for i, a in enumerate(A):
    g ^= a
    q.append((-a, i))

if g == 0:
    print(0)
else:
    print(1)

heapify(q)

while 1:
    tmpa = []
    while g != 0:
        x,i = heappop(q)
        gtmp = g ^ A[i]
        if gtmp < A[i]:
            subt = A[i] - gtmp
            A[i] = gtmp
            g = 0
            print(i + 1,subt)
            rec()
            if gtmp > 0:
                tmpa.append((gtmp,i))
        else:
            tmpa.append((x,i))

    for xx in tmpa:
        heappush(q,xx)

    inp()
    rec()

0