結果
問題 | No.3143 Colorless Green Parentheses Sleep Furiously |
ユーザー |
![]() |
提出日時 | 2025-05-16 22:45:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 912 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,648 KB |
実行使用メモリ | 95,544 KB |
最終ジャッジ日時 | 2025-05-17 00:34:10 |
合計ジャッジ時間 | 5,059 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 WA * 1 |
ソースコード
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)) elif(v > K): print("No") else: anss = "".join(ans) try: eval(anss[1:-1]) print("No") except: print("Yes") print(anss)