結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 07:55:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,448 ms / 3,500 ms
コード長 1,421 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 211,472 KB
実行使用メモリ 61,712 KB
最終ジャッジ日時 2023-08-11 13:39:16
合計ジャッジ時間 20,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 136 ms
20,276 KB
testcase_13 AC 135 ms
20,320 KB
testcase_14 AC 135 ms
20,356 KB
testcase_15 AC 54 ms
14,724 KB
testcase_16 AC 61 ms
14,760 KB
testcase_17 AC 67 ms
14,852 KB
testcase_18 AC 618 ms
31,784 KB
testcase_19 AC 559 ms
30,200 KB
testcase_20 AC 1,180 ms
50,028 KB
testcase_21 AC 1,230 ms
53,796 KB
testcase_22 AC 1,364 ms
50,564 KB
testcase_23 AC 834 ms
36,952 KB
testcase_24 AC 1,448 ms
61,560 KB
testcase_25 AC 1,437 ms
61,572 KB
testcase_26 AC 1,445 ms
61,712 KB
testcase_27 AC 1,152 ms
36,712 KB
testcase_28 AC 1,192 ms
36,740 KB
testcase_29 AC 1,065 ms
36,648 KB
testcase_30 AC 873 ms
36,636 KB
testcase_31 AC 1,426 ms
61,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma optimize("Ofast")
#pragma target("avx2")
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/modint.hpp>
using mint=atcoder::static_modint<998244353>;
#define endl '\n'
using lint=long long;
#define all(n) (n).begin(),(n).end()

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    vector<vector<int>>s(n+1);
    s[0].emplace_back(0);
    for(int i=0;i<n;++i){
        for(auto e:s[i]){
            s[i+1].emplace_back(e|a[i]);
        }
        s[i+1].emplace_back(a[i]);
        s[i+1].emplace_back(0);
        sort(all(s[i+1]));
        s[i+1].erase(unique(all(s[i+1])),s[i+1].end());
    }
    mint ans=0;
    vector<mint>dp={1};
    for(int i=0;i<n;++i){
        bitset<1024>g;
        int to=0;
        auto get=[&](const vector<int>&x,int i){
            return lower_bound(all(x),i)-x.begin();
        };
        for(int j=0;j<s[i].size();++j){
            for(int k=0;k<=j;++k){
                const int d=s[i][j],e=s[i][k];
                if(d<e)break;
                if((d|e)==d){
                    g[get(s[i+1],e|a[i])*32+j]=1;
                }
            }
        }
        vector<mint>dp2(s[i+1].size());
        for(auto j=g._Find_first();j<1024;j=g._Find_next(j)){
            dp2[j/32]+=dp[j%32];
            if(i+1==n)ans+=dp[j%32];
        }
        swap(dp,dp2);
    }
    cout<<ans.val()<<endl;
}
0