結果

問題 No.5001 排他的論理和でランニング
ユーザー はむ吉🐹
提出日時 2018-03-21 16:24:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 478 ms / 1,500 ms
コード長 722 bytes
コンパイル時間 267 ms
実行使用メモリ 124,844 KB
スコア 49,807,152
最終ジャッジ日時 2020-03-12 20:20:36
ジャッジサーバーID
(参考情報)
judge8 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import functools
import itertools
import operator
import random


NUM_MAX_TRIAL = 20


def fold_xor(iterable):
    return functools.reduce(operator.xor, iterable)


def in_place_solve(m, xs, num_max_trial=NUM_MAX_TRIAL):
    random.shuffle(xs)
    max_score = 0
    res = None
    for i, ys in enumerate(itertools.combinations(xs, m)):
        if i >= num_max_trial:
            break
        score = fold_xor(ys)
        if score > max_score:
            max_score = score
            res = ys
    return res


def main():
    _, m = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    res = in_place_solve(m, xs)
    print(*res)


if __name__ == '__main__':
    main()
0