結果
| 問題 | No.3143 Colorless Green Parentheses Sleep Furiously |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-05-16 22:38:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 769 bytes |
| 記録 | |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 95,852 KB |
| 実行使用メモリ | 106,880 KB |
| 最終ジャッジ日時 | 2026-07-10 19:23:49 |
| 合計ジャッジ時間 | 6,879 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 WA * 2 |
ソースコード
N,K = list(map(int,input().split()))
S = input()
stack = []
for i in S:
if(i == "("):
stack.append("(")
else:
if(stack):
stack.pop()
else:
print("No")
exit()
if(stack):
print("No")
exit()
ans = []
for i in range(N-1):
if(S[i:i+2] == "(("):
ans.append("(")
ans.append("1")
ans.append("+")
elif(S[i:i+2] == "()"):
ans.append("(")
ans.append("1")
ans.append("+")
ans.append("1")
elif(S[i:i+2] == ")("):
ans.append(")")
ans.append("+")
elif(S[i:i+2] == "))"):
ans.append(")")
ans.append(S[-1])
v = ans.count("1")
if(v <= K):
print("Yes")
print("".join(ans)+"+1"*(K-v))
else:
print("No")
回転