結果
| 問題 |
No.2171 OR Assignment
|
| コンテスト | |
| ユーザー |
norikame
|
| 提出日時 | 2022-12-24 00:43:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 3,500 ms |
| コード長 | 916 bytes |
| コンパイル時間 | 5,346 ms |
| コンパイル使用メモリ | 311,072 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 07:11:42 |
| 合計ジャッジ時間 | 8,149 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
//
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()
const ll mod = 998244353LL;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<pair<int, ll>> dp, ndp;
dp.emplace_back(a[0], 1);
rep3(i, 1, n) {
ndp.emplace_back(a[i], dp.front().second);
for (const auto& pi : dp) if ((pi.first|a[i]) != ndp.back().first) ndp.emplace_back(pi.first|a[i], pi.second);
int len = ndp.size();
rep3r(j, 1, len) ndp[j-1].second = (ndp[j-1].second + ndp[j].second) % mod;
swap(ndp, dp);
ndp.clear();
}
cout << dp[0].second << endl;
return 0;
}
norikame