結果
問題 | No.1017 Reiwa Sequence |
ユーザー | dn6049949 |
提出日時 | 2020-04-03 23:16:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,528 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 82,284 KB |
実行使用メモリ | 107,480 KB |
最終ジャッジ日時 | 2024-07-03 06:09:16 |
合計ジャッジ時間 | 38,257 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
55,040 KB |
testcase_01 | AC | 51 ms
54,528 KB |
testcase_02 | AC | 50 ms
55,040 KB |
testcase_03 | AC | 51 ms
55,808 KB |
testcase_04 | AC | 51 ms
54,656 KB |
testcase_05 | AC | 50 ms
54,912 KB |
testcase_06 | AC | 50 ms
54,912 KB |
testcase_07 | AC | 50 ms
54,784 KB |
testcase_08 | AC | 50 ms
54,912 KB |
testcase_09 | WA | - |
testcase_10 | AC | 215 ms
94,816 KB |
testcase_11 | AC | 59 ms
63,104 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 63 ms
64,512 KB |
testcase_15 | AC | 69 ms
66,816 KB |
testcase_16 | AC | 64 ms
65,152 KB |
testcase_17 | AC | 92 ms
77,256 KB |
testcase_18 | AC | 63 ms
64,896 KB |
testcase_19 | AC | 189 ms
85,316 KB |
testcase_20 | AC | 198 ms
88,192 KB |
testcase_21 | AC | 158 ms
83,072 KB |
testcase_22 | AC | 200 ms
87,552 KB |
testcase_23 | AC | 205 ms
88,944 KB |
testcase_24 | AC | 242 ms
93,824 KB |
testcase_25 | AC | 200 ms
88,576 KB |
testcase_26 | AC | 174 ms
85,308 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 206 ms
93,184 KB |
testcase_30 | AC | 224 ms
94,160 KB |
testcase_31 | WA | - |
testcase_32 | AC | 141 ms
85,092 KB |
testcase_33 | WA | - |
testcase_34 | AC | 50 ms
55,168 KB |
testcase_35 | AC | 50 ms
55,424 KB |
testcase_36 | AC | 49 ms
54,784 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 195 ms
91,648 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 | AC | 122 ms
102,528 KB |
testcase_49 | WA | - |
testcase_50 | AC | 122 ms
103,040 KB |
testcase_51 | WA | - |
testcase_52 | AC | 187 ms
85,504 KB |
testcase_53 | AC | 115 ms
81,536 KB |
ソースコード
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def solve(): n = I() a = LI() d = defaultdict(lambda : 0) for i in a: if d[i]: d[i] += 1 break d[i] = 1 if d[i] == 2: print("Yes") ans = [] for j in a: if j == i and d[j]: ans.append((2*d[j]-3)*j) d[j] -= 1 else: ans.append(0) print(*ans) return if n > 21: print("No") return f = [0,1,-1] dpl = defaultdict(lambda : None) dpl[0] = 0 dpl[a[0]] = 1 dpl[-a[0]] = 2 l = set(dpl.keys()) n1 = n>>1 for ii in range(1,n1): b = 3**ii ai = a[ii] for i in l: for k in range(3): ni = f[k]*ai+i nj = dpl[i]+b*k if nj: dpl[ni] = nj l = set(dpl.keys()) n2 = n-n1 dpr = defaultdict(lambda : None) dpr[0] = 0 dpr[a[n1]] = 1 dpr[-a[n1]] = 2 l = set(dpr.keys()) for ii in range(1,n2): b = 3**ii ai = a[ii+n1] for i in l: for k in range(3): ni = f[k]*ai+i nj = dpr[i]+b*k if nj: dpr[ni] = nj l = set(dpr.keys()) dpr = list(dpr.items()) dpr.sort() for i,j in dpl.items(): b = bisect.bisect_left(dpr,(i,j)) if b >= len(dpr): continue if dpr[b][0] == i and j+dpr[b][1]: k = dpr[b][1] break else: print("No") return ans = [] for i in range(n1): ans.append(a[i]*f[j%3]) j //= 3 for i in range(n2): ans.append(-a[i+n1]*f[k%3]) k //= 3 print("Yes") print(*ans) return #Solve if __name__ == "__main__": solve()