結果
| 問題 |
No.2171 OR Assignment
|
| コンテスト | |
| ユーザー |
hotman78
|
| 提出日時 | 2022-12-23 07:42:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,279 bytes |
| コンパイル時間 | 2,774 ms |
| コンパイル使用メモリ | 218,820 KB |
| 最終ジャッジ日時 | 2025-02-09 18:59:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 TLE * 10 |
ソースコード
#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;
map<lint,mint>dp;
dp[0]=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());
map<lint,mint>dp2;
for(auto [s,t]:g){
dp2[t]+=dp[s];
if(i+1==n){
ans+=dp[s];
}
}
swap(dp,dp2);
}
cout<<ans.val()<<endl;
}
hotman78