結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 07:38:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,231 bytes
コンパイル時間 2,683 ms
コンパイル使用メモリ 227,264 KB
実行使用メモリ 817,128 KB
最終ジャッジ日時 2024-04-29 05:58:40
合計ジャッジ時間 10,024 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 1,176 ms
171,080 KB
testcase_13 AC 1,187 ms
171,084 KB
testcase_14 AC 1,166 ms
171,220 KB
testcase_15 AC 154 ms
30,636 KB
testcase_16 AC 331 ms
49,328 KB
testcase_17 AC 301 ms
49,204 KB
testcase_18 MLE -
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'
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<pair<lint,lint>>g;
    for(int i=0;i<n;++i){
        for(auto d:s[i]){
            for(auto e:s[i]){
                if(d<e)break;
                if((d|e)==d){
                    g.emplace_back((lint(i)<<31)+d,(lint(i+1)<<31)+(e|a[i]));
                }
            }
        }
    }
    sort(all(g));
    g.erase(unique(all(g)),g.end());
    map<lint,mint>dp;
    dp[0]=1;
    for(auto [s,t]:g){
        dp[t]+=dp[s];
        if((t>>31)==n){
            ans+=dp[s];
        }
    }
    cout<<ans.val()<<endl;
}
0