結果
問題 | No.1017 Reiwa Sequence |
ユーザー | dn6049949 |
提出日時 | 2020-04-03 23:15:22 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,481 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 105,856 KB |
最終ジャッジ日時 | 2024-07-03 06:03:04 |
合計ジャッジ時間 | 37,764 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
54,656 KB |
testcase_01 | RE | - |
testcase_02 | AC | 50 ms
54,912 KB |
testcase_03 | AC | 52 ms
55,168 KB |
testcase_04 | AC | 49 ms
54,400 KB |
testcase_05 | AC | 50 ms
54,528 KB |
testcase_06 | AC | 50 ms
54,272 KB |
testcase_07 | AC | 50 ms
54,528 KB |
testcase_08 | AC | 49 ms
54,272 KB |
testcase_09 | RE | - |
testcase_10 | AC | 216 ms
94,464 KB |
testcase_11 | AC | 57 ms
63,360 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | AC | 92 ms
76,544 KB |
testcase_18 | AC | 62 ms
64,896 KB |
testcase_19 | AC | 183 ms
85,120 KB |
testcase_20 | AC | 193 ms
87,680 KB |
testcase_21 | AC | 154 ms
83,072 KB |
testcase_22 | AC | 194 ms
87,680 KB |
testcase_23 | AC | 201 ms
88,704 KB |
testcase_24 | RE | - |
testcase_25 | AC | 193 ms
88,448 KB |
testcase_26 | AC | 168 ms
85,120 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 202 ms
93,440 KB |
testcase_30 | AC | 216 ms
94,208 KB |
testcase_31 | WA | - |
testcase_32 | AC | 140 ms
84,992 KB |
testcase_33 | WA | - |
testcase_34 | AC | 50 ms
54,784 KB |
testcase_35 | AC | 50 ms
54,784 KB |
testcase_36 | AC | 50 ms
55,168 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 192 ms
91,392 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 | 117 ms
102,144 KB |
testcase_49 | WA | - |
testcase_50 | AC | 119 ms
103,168 KB |
testcase_51 | WA | - |
testcase_52 | AC | 180 ms
85,376 KB |
testcase_53 | AC | 112 ms
81,152 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 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()