結果

問題 No.1444 !Andd
ユーザー first_vilfirst_vil
提出日時 2021-01-23 15:36:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 197,844 KB
実行使用メモリ 43,656 KB
最終ジャッジ日時 2023-08-29 22:05:48
合計ジャッジ時間 5,213 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,800 KB
testcase_01 AC 2 ms
5,516 KB
testcase_02 AC 2 ms
5,704 KB
testcase_03 AC 27 ms
14,212 KB
testcase_04 AC 19 ms
12,776 KB
testcase_05 AC 4 ms
5,676 KB
testcase_06 AC 21 ms
13,072 KB
testcase_07 AC 17 ms
12,552 KB
testcase_08 AC 45 ms
21,620 KB
testcase_09 AC 28 ms
16,380 KB
testcase_10 AC 3 ms
5,960 KB
testcase_11 AC 3 ms
5,640 KB
testcase_12 AC 53 ms
25,916 KB
testcase_13 AC 75 ms
33,744 KB
testcase_14 AC 7 ms
6,504 KB
testcase_15 AC 70 ms
33,356 KB
testcase_16 AC 109 ms
43,560 KB
testcase_17 AC 24 ms
11,160 KB
testcase_18 AC 106 ms
43,588 KB
testcase_19 AC 110 ms
43,656 KB
testcase_20 AC 109 ms
43,628 KB
testcase_21 AC 109 ms
43,628 KB
testcase_22 AC 107 ms
43,632 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