結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 07:11:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,145 bytes
コンパイル時間 2,843 ms
コンパイル使用メモリ 228,184 KB
実行使用メモリ 216,320 KB
最終ジャッジ日時 2024-04-29 05:58:30
合計ジャッジ時間 10,715 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 662 ms
93,440 KB
testcase_13 AC 655 ms
93,440 KB
testcase_14 AC 653 ms
93,568 KB
testcase_15 AC 102 ms
43,136 KB
testcase_16 AC 160 ms
52,352 KB
testcase_17 AC 137 ms
52,480 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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'

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<set<int>>ss(n+1);
    vector<vector<int>>s(n+1);
    vector<map<int,mint>>dp(n+1);
    ss[0].emplace(0);
    for(int i=0;i<n;++i){
        for(auto e:ss[i]){
            ss[i+1].emplace(e|a[i]);
        }
        ss[i+1].emplace(a[i]);
        ss[i+1].emplace(0);
    }
    for(int i=0;i<n;++i)s[i]=vector(ss[i].begin(),ss[i].end());
    ss=vector<set<int>>();
    mint ans=0;
    dp[0][0]=1;
    for(int i=0;i<n;++i){
        for(auto [d,c]:dp[i]){
            unordered_set<long long>used;
            for(auto e:s[i]){
                if(used.count(d*(1LL<<31)+(e|a[i])))continue;
                if((d|e)==d){
                    dp[i+1][e|a[i]]+=c;
                    used.emplace(d*(1LL<<31)+(e|a[i]));
                }
            }
        }
    }
    for(auto [e,c]:dp[n])ans+=c;
    cout<<ans.val()<<endl;
}
0