結果

問題 No.2171 OR Assignment
ユーザー norikamenorikame
提出日時 2022-12-24 00:43:52
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 3,500 ms
コード長 916 bytes
コンパイル時間 6,049 ms
コンパイル使用メモリ 309,936 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-11 13:44:22
合計ジャッジ時間 8,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,388 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 80 ms
4,380 KB
testcase_13 AC 78 ms
4,384 KB
testcase_14 AC 79 ms
4,384 KB
testcase_15 AC 29 ms
4,384 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 72 ms
4,384 KB
testcase_18 AC 82 ms
4,384 KB
testcase_19 AC 44 ms
4,380 KB
testcase_20 AC 55 ms
4,380 KB
testcase_21 AC 56 ms
4,384 KB
testcase_22 AC 61 ms
4,380 KB
testcase_23 AC 77 ms
4,384 KB
testcase_24 AC 81 ms
4,384 KB
testcase_25 AC 76 ms
4,380 KB
testcase_26 AC 71 ms
4,380 KB
testcase_27 AC 69 ms
4,384 KB
testcase_28 AC 69 ms
4,384 KB
testcase_29 AC 75 ms
4,380 KB
testcase_30 AC 83 ms
4,380 KB
testcase_31 AC 81 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#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;
}
0