結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 06:59:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 895 bytes
コンパイル時間 2,728 ms
コンパイル使用メモリ 225,088 KB
実行使用メモリ 430,208 KB
最終ジャッジ日時 2024-04-29 05:57:24
合計ジャッジ時間 18,004 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 584 ms
130,688 KB
testcase_13 AC 573 ms
130,816 KB
testcase_14 AC 576 ms
130,944 KB
testcase_15 AC 101 ms
41,472 KB
testcase_16 AC 148 ms
55,552 KB
testcase_17 AC 169 ms
50,816 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/modint.hpp>
using mint=atcoder::static_modint<998244353>;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    vector<set<int>>s(n+1);
    vector<map<int,mint>>dp(n+1);
    s[0].emplace(0);
    for(int i=0;i<n;++i){
        for(auto e:s[i]){
            s[i+1].emplace(e|a[i]);
        }
        s[i+1].emplace(a[i]);
        s[i+1].emplace(0);
    }
    mint ans=0;
    dp[0][0]=1;
    for(int i=0;i<n;++i){
        for(auto [d,c]:dp[i]){
            set<pair<int,int>>used;
            for(auto e:s[i]){
                if(used.count(make_pair(d,e|a[i])))continue;
                if((d|e)==d){
                    dp[i+1][e|a[i]]+=c;
                    used.emplace(d,e|a[i]);
                }
            }
        }
    }
    for(auto [e,c]:dp[n])ans+=c;
    cout<<ans.val()<<endl;
}
0