結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
53,760 KB
testcase_01 AC 48 ms
53,504 KB
testcase_02 AC 47 ms
53,888 KB
testcase_03 AC 56 ms
62,080 KB
testcase_04 AC 48 ms
53,760 KB
testcase_05 AC 46 ms
53,760 KB
testcase_06 AC 47 ms
53,632 KB
testcase_07 AC 48 ms
53,888 KB
testcase_08 AC 47 ms
53,760 KB
testcase_09 AC 58 ms
63,232 KB
testcase_10 AC 347 ms
127,788 KB
testcase_11 AC 57 ms
62,720 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 62 ms
63,360 KB
testcase_15 AC 64 ms
64,128 KB
testcase_16 AC 64 ms
63,232 KB
testcase_17 AC 70 ms
67,456 KB
testcase_18 AC 66 ms
63,488 KB
testcase_19 AC 386 ms
151,748 KB
testcase_20 AC 393 ms
151,824 KB
testcase_21 AC 397 ms
151,948 KB
testcase_22 AC 399 ms
151,692 KB
testcase_23 AC 382 ms
151,812 KB
testcase_24 AC 387 ms
151,696 KB
testcase_25 AC 383 ms
151,824 KB
testcase_26 AC 364 ms
151,564 KB
testcase_27 AC 348 ms
151,148 KB
testcase_28 AC 360 ms
151,408 KB
testcase_29 AC 362 ms
151,468 KB
testcase_30 AC 366 ms
151,384 KB
testcase_31 AC 369 ms
150,864 KB
testcase_32 AC 361 ms
149,992 KB
testcase_33 AC 332 ms
144,564 KB
testcase_34 AC 344 ms
140,276 KB
testcase_35 AC 316 ms
144,196 KB
testcase_36 AC 327 ms
144,236 KB
testcase_37 AC 351 ms
149,104 KB
testcase_38 AC 329 ms
153,072 KB
testcase_39 AC 351 ms
149,748 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 AC 1,261 ms
280,336 KB
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 AC 1,218 ms
253,508 KB
testcase_50 AC 1,128 ms
243,256 KB
testcase_51 AC 48 ms
54,144 KB
testcase_52 AC 338 ms
151,944 KB
testcase_53 AC 340 ms
151,804 KB
権限があれば一括ダウンロードができます

ソースコード

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

for x in dic.keys():
    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