結果

問題 No.1444 !Andd
ユーザー iaNTUiaNTU
提出日時 2021-01-22 18:15:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 746 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 198,380 KB
実行使用メモリ 13,160 KB
最終ジャッジ日時 2023-08-29 22:11:36
合計ジャッジ時間 5,156 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,564 KB
testcase_01 AC 2 ms
5,744 KB
testcase_02 AC 2 ms
5,564 KB
testcase_03 AC 27 ms
13,040 KB
testcase_04 AC 19 ms
10,532 KB
testcase_05 RE -
testcase_06 AC 21 ms
10,992 KB
testcase_07 AC 17 ms
10,304 KB
testcase_08 RE -
testcase_09 AC 28 ms
13,160 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int kN = int(5E3 + 10);
constexpr int kC = 1 << 10;

int a[kN];
bool now[kN][kC], dp[kN][kC];

int main() {
	int n, ans = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	now[0][1] = true;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) {
			while (i++ <= n) printf("1\n");
			break;
		}
		for (int j = 0; j < kC; j++) if (now[i - 1][j]) dp[i][j & a[i]] = true;
		for (int j = 0; j < kC; j++) if (dp[i][j]) ans++;
		if (now[i - 1][1] && dp[i][a[i]]) ans--;
		if (dp[i - 1][0]) ans--;
		for (int j = 0; j < kC; j++) if (now[i - 1][j]) now[i][(j * a[i]) & (kC - 1)] = true;
		for (int j = 0; j < kC; j++) if (dp[i][j]) now[i][j] = true;
		printf("%d\n", ans);
	}
}
0