結果

問題 No.2071 Shift and OR
ユーザー rlangevin
提出日時 2023-01-27 22:02:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 110,080 KB
最終ジャッジ日時 2024-06-28 07:05:39
合計ジャッジ時間 7,978 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 7 TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def shift(x):
    return ((x % 2) << 15) + x//2

N =int(input())
A = list(map(int, input().split()))
dp = [0] * (N + 1)
L = []
for i in range(N):
    p = A[i]
    for j in range(16):
        v = p
        for a in L:
            v |= a
        if v not in L:
            L.append(p)
            break            
        p = shift(p)
        
dp = [0] * (1 << 16)
dp[0] = 1 
M = len(L)
pre = set([0])
for i in range(M):
    S = set()
    v = A[i]
    for s in range(1 << 16):
        for j in range(16):
            if dp[s]:
                S.add(s|v)
            v = shift(v)
    for b in S:
        dp[b] = 1
    for c in pre:
        dp[c] = 0
    pre, S = S, pre

for i in range(2 ** 16 - 1, -1, -1):
    if dp[i]:
        print(i)
        break        
0