結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 07:06:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 998 bytes
コンパイル時間 3,068 ms
コンパイル使用メモリ 224,688 KB
実行使用メモリ 425,600 KB
最終ジャッジ日時 2024-04-29 05:58:59
合計ジャッジ時間 18,715 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 526 ms
130,688 KB
testcase_13 AC 529 ms
130,688 KB
testcase_14 AC 527 ms
130,688 KB
testcase_15 AC 81 ms
41,344 KB
testcase_16 AC 130 ms
55,552 KB
testcase_17 AC 113 ms
51,072 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 #

#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>>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