結果

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

ソースコード

diff #

n,k=map(int,input().split())
s=input()
t=s
q=[]
f=0
for i in range(n):
  c=s[i]
  q+=c,
  if q[-2:]==[*'()']:
    q.pop()
    q.pop()
  if not q and i+1<n:
    f=1
if q:
  exit(print('No'))
s=t.count('()')
t=t.replace('()','(1)')
s+=t.count('(')
t=t.replace('(','(1+')
t=t.replace(')(',')+(')
if f<1:
  t+='+1'
  s+=1
# s=eval(t)
if s>k:
  exit(print('No'))
print('Yes')
print(t+'+1'*(k-s))
0