結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー ID 21712
提出日時 2025-05-16 23:27:29
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 499 bytes
コンパイル時間 16,253 ms
コンパイル使用メモリ 237,752 KB
実行使用メモリ 10,552 KB
最終ジャッジ日時 2025-05-17 00:36:39
合計ジャッジ時間 29,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46 WA * 2 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"
import . "strings"
func main() {
	var n,k int
	var s string
	Scan(&n,&k,&s)
	t:=""
	x:=0
	for i,c:=range s {
		if c=='(' {
			x++
			if i>0&&s[i-1]==')' {
				t+="+"
			}
			t+="("
		} else {
			x--
			if x<0 {
				Println("No")
				return
			}
			if s[i-1]=='(' {
				t+="1+1)"
				k-=2
			} else {
				t+="+1)"
				k--
			}
			if k <0 {
				Println("No")
				return
			}
		}
	}
	t+=Repeat("+1",k)
	if x==0 {
		Println("Yes")
		Println(t)
	} else {
		Println("No")
	}
}
0