結果

問題 No.3822 Permuted Pairwise XOR
コンテスト
ユーザー kidodesu
提出日時 2026-11-22 13:14:53
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 176 ms / 2,000 ms
+ 534µs
コード長 676 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 64,636 KB
実行使用メモリ 60,040 KB
最終ジャッジ日時 2026-11-22 13:15:00
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    n = int(input())
    A = list(map(int, input().split()))
    def make(s):
        Ans = [A[s]]
        X = [1] * n
        X[s] = 0
        for _ in range(n-1):
            t = -1
            idx = -1
            for i in range(n):
                if not X[i]: continue
                if Ans[-1]^A[i] > t:
                    t = Ans[-1]^A[i]
                    idx = i
            Ans.append(A[idx])
            X[idx] = 0
        return Ans
    
    B = [make(i) for i in range(n)]
    C = [[B[i][j]^B[i][j+1] for j in range(n-1)] for i in range(n)]
    I = [i for i in range(n)]
    I.sort(key = lambda x: (C[x], B[x]))
    return B[I[-1]]

print(*main())
0