結果

問題 No.698 ペアでチームを作ろう
ユーザー ntuda
提出日時 2024-10-20 16:53:13
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 540 ms / 1,000 ms
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 282 ms
コンパイル使用メモリ 85,456 KB
実行使用メモリ 81,372 KB
最終ジャッジ日時 2026-05-05 17:32:09
合計ジャッジ時間 6,832 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def search(x):
    j = 0
    for i in range(N):
        if NU[i] == True:
            if j == x:
                return i
            j += 1

def dfs(x):
    global ans, sum0
    if x == 0:
        ans = max(ans, sum0)
        return
    a = NU.index(True)
    NU[a] = False
    for b in range(a + 1,N):
        if True not in NU[b:]:
            continue
        c = NU[b:].index(True) + b
        NU[c] = False
        sum0 += A[a] ^ A[c]
        dfs(x - 1)
        sum0 -= A[a] ^ A[c]
        NU[c] = True
    NU[a] = True

N = int(input())
A = list(map(int, input().split()))
NU = [True] * N
ans = 0
sum0 = 0
dfs(N//2)
print(ans)
0