結果
| 問題 | No.2171 OR Assignment |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-23 01:26:41 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 3,500 ms |
| コード長 | 1,127 bytes |
| 記録 | |
| コンパイル時間 | 1,133 ms |
| コンパイル使用メモリ | 82,768 KB |
| 最終ジャッジ日時 | 2025-02-09 18:50:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
#include <atcoder/modint>
using mint = atcoder::modint998244353;
constexpr int L = 30;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (auto &&e : a) std::cin >> e;
std::vector<int> ppos;
std::vector<mint> pd { 1 };
for (int i = 0; i < n; ++i) {
std::vector<int> pos { i };
int orv = a[i];
for (auto it = ppos.rbegin(); it != ppos.rend(); ++it) {
const int p = *it, norv = orv | a[p];
if (norv != orv) {
pos.push_back(p);
orv = norv;
}
}
std::reverse(pos.begin(), pos.end());
const int siz = pos.size();
std::vector<mint> dp(siz + 1);
for (int k = 0, j = 0; k < siz; ++k) {
while (j < int(ppos.size()) and ppos[j] <= pos[k]) ++j;
dp[k + 1] = dp[k] + pd[j];
}
pd.swap(dp);
ppos.swap(pos);
}
std::cout << pd.back().val() << std::endl;
return 0;
}