結果

問題 No.1017 Reiwa Sequence
ユーザー NoneNone
提出日時 2021-04-29 02:15:21
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 803 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 204,452 KB
最終ジャッジ日時 2023-09-22 09:09:45
合計ジャッジ時間 28,205 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,296 KB
testcase_01 AC 68 ms
71,588 KB
testcase_02 AC 69 ms
71,380 KB
testcase_03 AC 71 ms
75,652 KB
testcase_04 AC 68 ms
71,484 KB
testcase_05 AC 67 ms
71,456 KB
testcase_06 AC 66 ms
71,500 KB
testcase_07 AC 67 ms
71,488 KB
testcase_08 AC 67 ms
71,376 KB
testcase_09 AC 72 ms
76,212 KB
testcase_10 AC 139 ms
84,440 KB
testcase_11 AC 72 ms
76,016 KB
testcase_12 AC 666 ms
141,740 KB
testcase_13 AC 660 ms
141,316 KB
testcase_14 AC 73 ms
76,048 KB
testcase_15 AC 71 ms
76,356 KB
testcase_16 AC 71 ms
76,236 KB
testcase_17 AC 74 ms
77,756 KB
testcase_18 AC 71 ms
76,172 KB
testcase_19 AC 221 ms
165,780 KB
testcase_20 AC 222 ms
165,800 KB
testcase_21 AC 219 ms
165,568 KB
testcase_22 AC 221 ms
165,984 KB
testcase_23 AC 221 ms
165,788 KB
testcase_24 AC 219 ms
165,572 KB
testcase_25 AC 220 ms
165,780 KB
testcase_26 AC 217 ms
165,764 KB
testcase_27 AC 195 ms
139,160 KB
testcase_28 AC 212 ms
150,020 KB
testcase_29 AC 137 ms
85,112 KB
testcase_30 AC 141 ms
86,844 KB
testcase_31 AC 149 ms
94,488 KB
testcase_32 AC 181 ms
123,440 KB
testcase_33 AC 138 ms
84,376 KB
testcase_34 AC 188 ms
123,608 KB
testcase_35 AC 136 ms
83,960 KB
testcase_36 AC 136 ms
83,980 KB
testcase_37 AC 184 ms
123,544 KB
testcase_38 AC 140 ms
83,920 KB
testcase_39 AC 184 ms
123,476 KB
testcase_40 AC 802 ms
204,200 KB
testcase_41 AC 801 ms
204,452 KB
testcase_42 AC 791 ms
203,044 KB
testcase_43 AC 803 ms
203,028 KB
testcase_44 AC 701 ms
158,644 KB
testcase_45 AC 802 ms
204,396 KB
testcase_46 AC 794 ms
203,072 KB
testcase_47 AC 792 ms
203,048 KB
testcase_48 AC 716 ms
170,096 KB
testcase_49 AC 711 ms
169,848 KB
testcase_50 AC 719 ms
170,456 KB
testcase_51 AC 68 ms
71,384 KB
testcase_52 AC 222 ms
165,644 KB
testcase_53 AC 161 ms
104,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def zeta(A,merge):
    """
    N=20程度まで
    A = 2^N 通り のフラグの立ち方に対する値。これをゼータ変換で累積していく。
    """
    _N = (len(A)-1).bit_length()
    dp = A[:]
    for k in range(_N):
        bit=1<<k
        for i in range(1<<_N):
            if i&bit:
                dp[i]=merge(dp[i^bit],dp[i])
    return dp

def main():
    used={}
    for bit in range(1<<N):
        s=S[bit]
        if s==0:
            continue
        if s not in used:
            used[s]=bit
        else:
            bit2=used[s]
            for i in range(N):
                cnt=0
                if bit&(1<<i):
                    cnt+=1
                if bit2&(1<<i):
                    cnt-=1
                res[i]=cnt*AA[i]
            return res
    return -1


###############################################################################
import sys
input = sys.stdin.readline

N=int(input())
AA=list(map(int, input().split()))
res=[0]*N
if len(AA)>22:
    AA=AA[:22]
    N=22
A=[0]*(1<<N)
for i in range(len(AA)):
    A[1<<i]=AA[i]
###################################
def merge(x,y):
    return x+y
S=zeta(A,merge)
###################################

res=main()
if res==-1:
    print("No")
else:
    print("Yes")
    print(*res)
0