結果

問題 No.2071 Shift and OR
ユーザー kuroni
提出日時 2022-09-16 23:00:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 169,052 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-21 22:28:45
合計ジャッジ時間 2,793 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    if (n >= 16) {
        return cout << 65535, 0;
    } else {
        vector<int> cur(1 << 16);
        cur[0] = 1;
        for (int i = 0; i < n; i++) {
            int u; cin >> u;
            vector<int> nxt(1 << 16);
            for (int j = 0; j < 16; j++) {
                u = u / 2 + ((u % 2) << 15);
                for (int t = 0; t < (1 << 16); t++) {
                    nxt[t | u] |= cur[t];
                }
            }
            for (int t = 0; t < (1 << 16); t++) {
                cur[t] |= nxt[t];
            }
        }
        for (int i = (1 << 16) - 1; i >= 0; i--) {
            if (cur[i]) {
                return cout << i, 0;
            }
        }
    }
}
0