結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー tkykwtnb
提出日時 2025-05-16 22:40:08
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 549 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,012 KB
実行使用メモリ 88,532 KB
最終ジャッジ日時 2025-05-17 00:33:35
合計ジャッジ時間 5,752 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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