結果

問題 No.2071 Shift and OR
コンテスト
ユーザー rlangevin
提出日時 2023-01-27 22:02:46
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 758 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 251 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 203,196 KB
最終ジャッジ日時 2026-03-16 18:30:17
合計ジャッジ時間 25,782 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 7 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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