結果

問題 No.699 ペアでチームを作ろう2
ユーザー GrayCoderGrayCoder
提出日時 2018-07-22 21:54:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 568 ms / 1,000 ms
コード長 885 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2023-08-27 01:00:54
合計ジャッジ時間 6,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,760 KB
testcase_01 AC 20 ms
8,620 KB
testcase_02 AC 24 ms
8,832 KB
testcase_03 AC 20 ms
8,752 KB
testcase_04 AC 58 ms
9,024 KB
testcase_05 AC 514 ms
9,728 KB
testcase_06 AC 501 ms
9,844 KB
testcase_07 AC 557 ms
14,008 KB
testcase_08 AC 568 ms
13,984 KB
testcase_09 AC 548 ms
13,888 KB
testcase_10 AC 560 ms
13,936 KB
testcase_11 AC 559 ms
13,936 KB
testcase_12 AC 559 ms
13,948 KB
testcase_13 AC 555 ms
13,944 KB
testcase_14 AC 563 ms
13,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import operator
from functools import reduce
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=None, dd=None, idx=0):
    nh = n // 2
    if d is None:
        d = [0] * nh
    if dd is None:
        dd = [0] * n
    if idx == n:
        pwr = [0] * nh
        for i in range(n):
            pwr[dd[i]] += A[i]
        Ret.append(reduce(operator.xor, 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