結果

問題 No.3594 Subset OR
ユーザー GOTKAKO
提出日時 2026-08-17 15:11:03
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 725 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,072 ms
コンパイル使用メモリ 211,796 KB
実行使用メモリ 134,632 KB
最終ジャッジ日時 2026-08-17 15:11:25
合計ジャッジ時間 19,915 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 1 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    using ull = unsigned long long;
    const int n = 1<<24;
    vector<ull> A(n);
    while(N--){
        int a; cin >> a;
        A.at(a>>6) |= 1ULL<<(a%64);
    }
    for(int d=0; d<24; d++) for(int i=0; i<n; i++){
        if((i>>d)&1) i += 1<<d,i--;
        else A.at(i+(1<<d)) |= A.at(i+(1<<d));
    }
    vector<ull> mask(6);
    for(int i=0; i<6; i++) for(int k=0; k<64; k++) if(k&(1<<i)) mask.at(i) |= 1ULL<<k;

    int answer = 0;
    for(auto a : A){
        for(int i=0; i<6; i++) a |= (a&mask.at(i))<<i;
        answer += __popcount(a);
    }
    cout << answer << endl;
}
0