結果
| 問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-16 22:47:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 943 bytes |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 82,564 KB |
| 実行使用メモリ | 91,008 KB |
| 最終ジャッジ日時 | 2025-05-17 00:34:14 |
| 合計ジャッジ時間 | 6,720 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 2 RE * 8 |
ソースコード
n, k = map(int, input().split())
assert 1 <= n <= 10**5
s = input()
a = [0]
b = [0]
for i in range(n):
if s[i] == "(": a.append(a[-1] + 1)
if s[i] == ")": a.append(a[-1] + -1)
for i in range(n - 1, -1, -1):
if s[i] == ")": b.append(b[-1] + 1)
if s[i] == "(": b.append(b[-1] + -1)
if not (a[-1] == 0 and min(a) == 0 and min(b) == 0):
assert False
print("No")
exit()
x = 0
ans = ["("]
depth = [0, 0]
for i in range(1, n):
if s[i] == ")":
use = depth.pop()
if use == 0:
ans.append("1+1)")
x += 2
elif use == 1:
ans.append("+1)")
x += 1
else:
ans.append(")")
depth[-1] += 1
else:
if s[i-1] == ")": ans.append("+")
ans.append("(")
depth.append(0)
if x <= k:
print("Yes")
ans.append("+1"*(k-x))
t = ''.join(ans)
assert ")(" not in t
print(t)
else:
print("No")