結果

問題 No.1444 !Andd
ユーザー XDXD
提出日時 2021-11-12 16:34:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 2,818 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 167,140 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-08-16 14:45:18
合計ジャッジ時間 4,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,408 KB
testcase_01 AC 2 ms
5,352 KB
testcase_02 AC 2 ms
5,348 KB
testcase_03 AC 18 ms
5,340 KB
testcase_04 AC 12 ms
5,564 KB
testcase_05 AC 2 ms
5,456 KB
testcase_06 AC 13 ms
5,372 KB
testcase_07 AC 11 ms
5,492 KB
testcase_08 AC 29 ms
5,376 KB
testcase_09 AC 18 ms
5,408 KB
testcase_10 AC 3 ms
5,468 KB
testcase_11 AC 2 ms
5,368 KB
testcase_12 AC 36 ms
5,512 KB
testcase_13 AC 50 ms
5,532 KB
testcase_14 AC 5 ms
5,532 KB
testcase_15 AC 48 ms
5,636 KB
testcase_16 AC 71 ms
5,540 KB
testcase_17 AC 13 ms
5,520 KB
testcase_18 AC 72 ms
5,676 KB
testcase_19 AC 73 ms
5,592 KB
testcase_20 AC 71 ms
5,552 KB
testcase_21 AC 70 ms
5,568 KB
testcase_22 AC 70 ms
5,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s); i<=(t); ++i)
#define forl(i,s,t) for(register i64 i=(s); i<=(t); ++i)
#define form(i,s,t) for(register int i=(s); i>=(t); --i)
#define rep(i,s,t) for(register int i=(s); i<(t); ++i)
#define IT(u) for(register int i=G[u]; i; i=E[i].nxt)
using namespace std;
namespace FASTIO {
	const int SIZ = 1 << 26 | 1;
	char ibuf[SIZ], obuf[SIZ], *iS = ibuf, *iT = ibuf, *oS = obuf, *oT = obuf + SIZ - 1, qwq[60], qaq;
	#define gc() (iS == iT && (iT = (iS = ibuf) + fread(ibuf, 1, SIZ, stdin), iS == iT) ? EOF : *iS++)
	template<typename T>
	inline void Rdn(T& A) {
		register bool fl = 0;
		register char ch = gc(); A = 0;
		while(!isdigit(ch)) fl = (ch == '-'), ch = gc();
		while(isdigit(ch)) A = (A * 10) + (ch & 15), ch = gc();
		fl && (A = -A);
	}
	inline void Rdn(char& c) {while((c = gc()) == ' ' || c == '\n' || c == '\r');}
	inline void Rdn(char* s) {
		while((*s = gc()) == ' ' || *s == '\n' || *s == '\r') ;
		if(*s == EOF) return ;
		while(*s != ' ' && *s != '\n' && *s != '\r' && *s != EOF) *(++s) = gc();
		*s = 0;
	}
	template<typename T, typename ...U>
	inline void Rdn(T& A, U& ...B) {Rdn(A), Rdn(B...);}
	inline void flush() {fwrite(obuf, 1, oS - obuf, stdout), oS = obuf;}
	inline void pc(char c) {*oS ++ = c; if(oS == oT) flush();}
	template<typename T>
	inline void Wtn(T A) {
		if(!A) return pc('0'); if(A < 0) pc('-'), A = -A;
		while(A) qwq[++qaq] = A % 10 + '0', A /= 10;
		while(qaq) pc(qwq[qaq -- ]);
	}
	inline void Wtn(char A) {pc(A);}
	inline void Wtn(char *s) {while(*s) pc(*s), ++s;}
	inline void Wtn(const char *s) {while(*s) pc(*s), ++s;}
	template<typename T, typename ...U>
	inline void Wtn(T A, U ...B) {Wtn(A), Wtn(B...);}
#undef gc
}
using FASTIO :: Rdn;
using FASTIO :: Wtn;
using FASTIO :: flush;
typedef long long i64;
typedef double f64;
typedef unsigned long long u64;
typedef pair<i64, i64> pii;
typedef pair<int, u64> piu;
const int N = 2e4 + 5;
const i64 INF = 1e18;
inline void init() {}
int n, a[N]; bool f[2][1 << 10]; int g[2][1 << 10];
inline void solve() {
	Rdn(n);
	forn (i, 1, n) Rdn(a[i]);
	int cur = 0, siz = (1 << 10) - 1;
	f[0][1] = 1; bool Zero = 0;
	forn (i, 1, n) {
		cur ^= 1;
		if (a[i] == 0 || Zero) {
			Zero = 1, Wtn("1\n"); continue ;
		}
		// * 
		rep (S, 0, 1 << 10) {
			g[cur][(S * a[i]) & (siz)] += g[cur ^ 1][S];
			if (S * a[i] < (1 << 10)) f[cur][S * a[i]] |= f[cur ^ 1][S];
			else g[cur][(S * a[i]) & (siz)] += f[cur ^ 1][S];
		}
		// &
		rep (S, 0, 1 << 10) {
			f[cur][S & a[i]] |= g[cur ^ 1][S] | f[cur ^ 1][S];
		}
		int ans = 0;
		rep (S, 0, 1 << 10) ans += f[cur][S] + g[cur][S];
		Wtn(ans, '\n');
		memset(f[cur ^ 1], 0, sizeof f[cur ^ 1]);
		memset(g[cur ^ 1], 0, sizeof g[cur ^ 1]); 
	}
}
int Trd;
int main() {
	Trd = 1;
	while(Trd--) init(), solve(); flush();
	return 0;
}
0