結果
| 問題 |
No.1017 Reiwa Sequence
|
| ユーザー |
maspy
|
| 提出日時 | 2020-03-09 16:06:15 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 662 ms / 2,000 ms |
| コード長 | 977 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 165,332 KB |
| 最終ジャッジ日時 | 2024-07-02 23:59:28 |
| 合計ジャッジ時間 | 55,786 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 50 |
ソースコード
#!/usr/bin/python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def solve_small(A):
N = len(A)
dp = np.zeros(1 << N, np.int32)
for i, x in enumerate(A):
dp[1 << i:1 << (i + 1)] = dp[:1 << i] + x
counts = np.bincount(dp)
if np.all(counts < 2):
return None
S = np.where(counts >= 2)[0][0]
I = np.where(dp == S)[0]
p = I[0]
q = I[1]
B = A.copy()
for i in range(N):
c = ((p >> i) & 1) - ((q >> i) & 1)
B[i] *= c
return B
def solve(A):
N = len(A)
K = 23
if N <= K:
return solve_small(A)
else:
A[:K] = solve_small(A[:K])
A[K:] = 0
return A
if __name__ == '__main__':
N = int(readline())
A = np.array(read().split(), np.int32)
A = solve(A)
if A is None:
print('No')
else:
print('Yes')
print(' '.join(map(str, A)))
maspy