結果

問題 No.3550 Another Rurumaru Function Problem
コンテスト
ユーザー ルク
提出日時 2026-04-24 22:49:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 1,210 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 149 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 123,684 KB
最終ジャッジ日時 2026-05-22 21:47:49
合計ジャッジ時間 15,901 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import fractions
from itertools import product
from collections import defaultdict
from collections import deque
inf = 1 << 60


def sgn(x):
    if x > 0:
        return 1
    elif x == 0:
        return 0
    else:
        return -1


def popC(x):
    ans = 0
    while x != 0:
        ans += x % 2
        x //= 2
    return ans


def LI():
    return list(map(int, input().split()))


def II():
    return int(input())


def SI():
    return input()


def f(x, y):
    ans = 0
    for i in range(60):
        bx = 0 if (x & (1 << i)) == 0 else 1
        by = 0 if (y & (1 << i)) == 0 else 1
        if i % 2:
            ans += (1 << i)*(bx | by)
        else:
            ans += (1 << i)*(bx & by)
    return ans

n = II()
a  =LI()
b = [0 for _ in range(1<<15)]
mask = 0b0101010101010101010101010101010101010101
for x in a:
    t = x&mask
    s = bin(t)[2:].zfill(30)
    s2 = []
    for i in range(15):
        s2.append(s[i*2+1])
    s2 = int("".join(s2),base=2)
    b[s2] |= x
ls = [i for i in range(1<<15)]
ls.sort(key=lambda x:popC(x),reverse=True)
for x in ls:
    for i in range(15):
        if x&(1<<i):
            x2 = x & ~(1 << i)
            b[x2] = max(b[x2],b[x],f(b[x2],b[x]))
print(max(b))
0