結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー tkykwtnb
提出日時 2025-05-16 22:25:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 1,736 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 89,356 KB
最終ジャッジ日時 2025-05-17 00:31:41
合計ジャッジ時間 6,009 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
        else:
            ans.append(s)
            stack.pop()
if len(stack)>0 or sm>K:exit(print("No"))
while sm<K:
    ans.append("+1")
    sm+=1
print("Yes")
print("".join(ans))
0