結果
| 問題 | No.1443 Andd | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-03-29 10:22:47 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 141 ms / 2,000 ms | 
| コード長 | 1,111 bytes | 
| コンパイル時間 | 1,470 ms | 
| コンパイル使用メモリ | 166,364 KB | 
| 実行使用メモリ | 53,888 KB | 
| 最終ジャッジ日時 | 2024-11-29 09:42:47 | 
| 合計ジャッジ時間 | 3,250 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
//
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)
typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;
const int N = 2e4;
const int M = (1 << 10) + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;
bool f[N][M][2];
bool cnt[N * M];
int a[N], s[N];
int main() {
	ios::sync_with_stdio(0);
	int upp = 1 << 10;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = n; i >= 0; i--)
		s[i] = s[i + 1] + a[i];
	f[0][0][1] = 1;
	cnt[s[0]] = 1;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < upp; j++) {
			for (int k = 0; k <= 1; k++) {
				if (!f[i][j][k]) continue;
				// add
				f[i + 1][(j + a[i + 1]) & (upp - 1)][0] = 1;
				// and
				f[i + 1][j & a[i + 1]][1] = 1;
			}
		}
		for (int j = 0; j < upp; j++) {
			if (f[i + 1][j][1] && cnt[j + s[i + 2]] == 0) {
				cnt[j + s[i + 2]] = 1;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
            
            
            
        