結果
| 問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-22 20:43:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 748 bytes |
| コンパイル時間 | 461 ms |
| コンパイル使用メモリ | 82,912 KB |
| 実行使用メモリ | 99,212 KB |
| 最終ジャッジ日時 | 2025-05-22 20:43:41 |
| 合計ジャッジ時間 | 6,854 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 WA * 1 |
ソースコード
N,K=map(int,input().split())
S=list(input())
stack=[]
ans=[]
sm=0
for s in S:
if s=="(":
if len(ans)>0 and ans[-1]==")":
ans.append("+")
ans.append(s)
ans.append("1+")
sm+=1
stack.append(s)
else:
if len(stack)==0:exit(print("No"))
if ans[-1]=="1+":
ans.append("1")
sm+=1
ans.append(s)
stack.pop()
if len(stack)>0 or sm>K:exit(print("No"))
while sm<K:
ans.append("+1")
sm+=1
stack=[]
pcnt=0
for a in ans:
if a=="+":
if len(stack)==0:pcnt+=1
elif a=="(":
stack.append(a)
elif a==")":
stack.pop()
if pcnt==0 and ans[0]=="(" and ans[-1]==")":exit(print("No"))
print("Yes")
print("".join(ans))