結果
| 問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
| コンテスト | |
| ユーザー |
timi
|
| 提出日時 | 2025-05-16 22:25:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 732 bytes |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 100,224 KB |
| 最終ジャッジ日時 | 2025-05-17 00:31:41 |
| 合計ジャッジ時間 | 6,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 WA * 2 |
ソースコード
from collections import deque
d=deque()
N,M=map(int, input().split())
S=input()
c=0
for s in S:
if s=='(':
c+=1
else:
c-=1
if c<0:
print('No')
exit()
if c!=0:
print('No')
exit()
A=[]
cnt=0
for s in S:
if s=='(':
d.append('(')
else:
if d[-1]=='(':
d.append('1')
d.append('+')
d.append('1')
cnt+=2
d.append(')')
ans=[]
while d:
c=d.popleft()
if len(ans)==0:
ans.append(c)
else:
if ans[-1]==')' and c=='(':
ans.append('+')
elif ans[-1]=='(' and c=='(':
ans.append('1')
ans.append('+')
cnt+=1
ans.append(c)
if cnt>M:
print('No')
else:
for i in range(M-cnt):
ans.append('+1')
print('Yes')
print(''.join(ans))
timi