結果

問題 No.698 ペアでチームを作ろう
ユーザー GrayCoderGrayCoder
提出日時 2018-07-22 20:59:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 522 ms / 1,000 ms
コード長 809 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 13,632 KB
最終ジャッジ日時 2023-08-27 00:59:55
合計ジャッジ時間 6,187 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,804 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 19 ms
7,724 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 51 ms
8,508 KB
testcase_05 AC 489 ms
9,176 KB
testcase_06 AC 479 ms
9,356 KB
testcase_07 AC 516 ms
13,484 KB
testcase_08 AC 516 ms
13,488 KB
testcase_09 AC 522 ms
13,632 KB
testcase_10 AC 517 ms
13,560 KB
testcase_11 AC 521 ms
13,428 KB
testcase_12 AC 519 ms
13,588 KB
testcase_13 AC 517 ms
13,560 KB
testcase_14 AC 522 ms
13,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    global A, Ret
    n = int(input())
    A = tuple(map(int, input().split()))

    Ret = []
    fp(n)
    print(max(Ret))

def fp(n, d=0, dd=0, idx=0):
    nh = n // 2
    if not d:
        d = [0] * nh
    if not dd:
        dd = [0] * n
    if idx == n:
        pwr = [0] * nh
        for i in range(n):
            pwr[dd[i]] ^= A[i]
        Ret.append(sum(pwr))
        return

    for i in range(nh):
        if d[i] == 0:
            d[i] = 1
            dd[idx] = i
            fp(n, d, dd, idx + 1)
            d[i] = 0
            break

    for i in range(nh):
        if d[i] == 1:
            d[i] = 2
            dd[idx] = i
            fp(n, d, dd, idx + 1)
            d[i] = 1

main()
0