結果

問題 No.1444 !Andd
ユーザー iaNTUiaNTU
提出日時 2021-01-24 17:52:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 199,072 KB
実行使用メモリ 43,680 KB
最終ジャッジ日時 2023-09-01 02:56:33
合計ジャッジ時間 5,145 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,724 KB
testcase_01 AC 2 ms
5,596 KB
testcase_02 AC 1 ms
5,588 KB
testcase_03 AC 28 ms
14,140 KB
testcase_04 AC 20 ms
12,668 KB
testcase_05 AC 3 ms
5,744 KB
testcase_06 AC 20 ms
13,144 KB
testcase_07 AC 18 ms
12,428 KB
testcase_08 AC 46 ms
21,640 KB
testcase_09 AC 28 ms
16,412 KB
testcase_10 AC 4 ms
5,664 KB
testcase_11 AC 3 ms
5,636 KB
testcase_12 AC 55 ms
25,756 KB
testcase_13 AC 75 ms
34,088 KB
testcase_14 AC 7 ms
6,508 KB
testcase_15 AC 71 ms
33,224 KB
testcase_16 AC 109 ms
43,556 KB
testcase_17 AC 24 ms
11,224 KB
testcase_18 AC 108 ms
43,576 KB
testcase_19 AC 112 ms
43,556 KB
testcase_20 AC 113 ms
43,628 KB
testcase_21 AC 111 ms
43,680 KB
testcase_22 AC 111 ms
43,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int kN = int(2E4 + 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