結果

問題 No.1017 Reiwa Sequence
ユーザー ygd.ygd.
提出日時 2021-05-18 15:07:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,052 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 306,960 KB
最終ジャッジ日時 2024-04-17 04:34:42
合計ジャッジ時間 12,973 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
59,136 KB
testcase_01 AC 49 ms
53,504 KB
testcase_02 AC 47 ms
53,632 KB
testcase_03 AC 58 ms
61,824 KB
testcase_04 AC 49 ms
53,248 KB
testcase_05 AC 49 ms
53,760 KB
testcase_06 AC 49 ms
53,504 KB
testcase_07 AC 48 ms
53,504 KB
testcase_08 AC 47 ms
53,504 KB
testcase_09 AC 62 ms
63,232 KB
testcase_10 AC 411 ms
138,012 KB
testcase_11 AC 60 ms
62,592 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

num = min(N, 22)

from collections import defaultdict 
dic = defaultdict(list)

for i in range(1,1<<num):
    temp = 0
    for j in range(num):
        if (i>>j)&1 == 1:
            temp += A[j]
    dic[temp].append(i)
#print(dic)

def overlap(p,q):
    for i in range(30):
        if (p>>i)&1 == 1 and (q>>i)&1 == 1:
            return False
    return True

ret = [0]*N

dicL = list(dic.keys())
dicL.sort()

for x in dicL:
    if len(dic[x]) <= 1: continue
    n = len(dic[x])
    for i in range(n):
        a = dic[x][i]
        for j in range(i+1,n):
            b = dic[x][j]
            if not overlap(a,b): continue
            for s in range(30):
                if (a>>s)&1 == 1:
                    ret[s] = A[s]
                if (b>>s)&1 == 1:
                    ret[s] = -A[s]
                Flag = 0
                if (a>>s)&1 == 1 and (b>>s)&1 == 1:
                    Flag = 1
                assert Flag == 0
            print("Yes")
            print(*ret); exit()
print("No")
0