結果
| 問題 | No.1443 Andd | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-03-26 23:21:15 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,075 ms / 2,000 ms | 
| コード長 | 1,766 bytes | 
| コンパイル時間 | 166 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 185,028 KB | 
| 最終ジャッジ日時 | 2024-11-29 01:36:31 | 
| 合計ジャッジ時間 | 9,113 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
class Dijkstra():
    class Edge():
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost
    def __init__(self, V):
        self.G = [[] for i in range(V)]
        self._E = 0
        self._V = V
    @property
    def E(self):
        return self._E
    @property
    def V(self):
        return self._V
    def add_edge(self, _from, _to, _cost):
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1
    def shortest_path(self, start):
        import heapq
        que = []
        d = [10**15] * self.V
        if type(start)==int:
            s = start
            d[s] = 0
            heapq.heappush(que, (0, s))
        else:
            for s in start:
                d[s] = 0
                heapq.heappush(que,(0,s))
        while len(que) != 0:
            cost, v = heapq.heappop(que)
            if d[v] < cost: continue
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    heapq.heappush(que, (d[e.to], e.to))
        return d
import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd
input = lambda :sys.stdin.buffer.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
N = int(input())
A = li()
bit = [False for i in range(1024)]
bit[0] = True
S = set([0])
SS = 0
for i in range(N):
    SS += A[i]
    nbit = [False for i in range(1024)]
    for b in range(1024):
        if bit[b]:
            nbit[b&A[i]] = True
            S.add((b&A[i])-SS)
            nbit[(b+A[i])%1024] = True
    bit = nbit
    print(len(S))
            
            
            
        