結果

問題 No.1017 Reiwa Sequence
ユーザー NoneNone
提出日時 2021-04-29 02:10:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,298 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 204,384 KB
最終ジャッジ日時 2023-09-22 09:06:30
合計ジャッジ時間 30,310 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,264 KB
testcase_01 AC 74 ms
71,016 KB
testcase_02 AC 75 ms
71,116 KB
testcase_03 AC 81 ms
75,456 KB
testcase_04 AC 75 ms
71,388 KB
testcase_05 AC 77 ms
71,444 KB
testcase_06 AC 74 ms
71,396 KB
testcase_07 AC 76 ms
71,436 KB
testcase_08 AC 74 ms
71,016 KB
testcase_09 AC 104 ms
76,016 KB
testcase_10 AC 147 ms
84,112 KB
testcase_11 AC 81 ms
75,772 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 82 ms
75,860 KB
testcase_15 AC 85 ms
75,860 KB
testcase_16 AC 83 ms
75,900 KB
testcase_17 AC 83 ms
77,288 KB
testcase_18 AC 81 ms
75,972 KB
testcase_19 AC 242 ms
165,388 KB
testcase_20 AC 239 ms
165,348 KB
testcase_21 AC 237 ms
165,656 KB
testcase_22 AC 243 ms
165,572 KB
testcase_23 AC 241 ms
165,576 KB
testcase_24 AC 243 ms
165,408 KB
testcase_25 AC 240 ms
165,572 KB
testcase_26 AC 234 ms
165,344 KB
testcase_27 AC 213 ms
139,224 KB
testcase_28 AC 224 ms
149,776 KB
testcase_29 AC 149 ms
84,968 KB
testcase_30 AC 149 ms
86,568 KB
testcase_31 AC 161 ms
94,060 KB
testcase_32 AC 194 ms
123,312 KB
testcase_33 AC 147 ms
84,232 KB
testcase_34 AC 194 ms
123,348 KB
testcase_35 AC 146 ms
83,604 KB
testcase_36 AC 144 ms
83,600 KB
testcase_37 AC 190 ms
123,212 KB
testcase_38 AC 145 ms
83,644 KB
testcase_39 AC 194 ms
123,316 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 75 ms
71,476 KB
testcase_52 AC 236 ms
165,492 KB
testcase_53 AC 168 ms
104,780 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:
            res=[0]*N
            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