結果

問題 No.2171 OR Assignment
ユーザー hotman78hotman78
提出日時 2022-12-23 07:47:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,393 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 221,344 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-04-29 05:59:48
合計ジャッジ時間 12,979 ms
ジャッジサーバーID
(参考情報)
judge2 / 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 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 58 ms
15,104 KB
testcase_16 WA -
testcase_17 AC 87 ms
14,976 KB
testcase_18 WA -
testcase_19 WA -
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'
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<lint>dp={1};
    for(int i=0;i<n;++i){
        vector<pair<int,int>>g;
        for(auto d:s[i]){
            for(auto e:s[i]){
                if(d<e)break;
                if((d|e)==d){
                    g.emplace_back(d,e|a[i]);
                }
            }
        }
        sort(all(g));
        g.erase(unique(all(g)),g.end());
        vector<lint>dp2(s[i+1].size());
        auto get=[&](const vector<int>&x,int i){
            return lower_bound(all(x),i)-x.begin();
        };
        for(auto [p,q]:g){
            dp2[get(s[i+1],q)]+=dp[get(s[i],p)];
            if(i+1==n)ans+=dp[get(s[i],p)];
        }
        swap(dp,dp2);
    }
    cout<<ans.val()<<endl;
}
0