結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー 👑 p-adic
提出日時 2025-03-11 08:08:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 304 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2025-05-17 00:19:31
合計ジャッジ時間 5,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:14: SyntaxWarning: invalid decimal literal
  if K<0 or b|d|(K==0and p==1):exit(O("No"))

ソースコード

diff #

I,O=input,print
N,K=map(int,I().split())
b=d=p=0
E=[]
for c in I():
	if c<')':
		d+=1;K-=1
		if E and E[-1][-1]==')':E+=["+(1+"]
		else:E+=["(1+"]
	else:
		d-=1;b|=d<0;p+=d==0
		if E and E[-1][-1]=='+':E+=["1)"];K-=1
		else:E+=[")"]
if K<0 or b|d|(K==0and p==1):exit(O("No"))
O("Yes\n"+''.join(E)+"+1"*K)
0