結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー ID 21712
提出日時 2025-05-16 23:44:33
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 13,173 ms
コンパイル使用メモリ 235,336 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-05-17 00:37:27
合計ジャッジ時間 16,816 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"
import . "strings"
func main() {
	var n,k int
	var s string
	Scan(&n,&k,&s)
	if n%2==1 {
		Println("No")
		return
	}
	if Count(s,"(")!=Count(s,")") {
		Println("No")
		return
	}
	x:=0
	for _,c:=range s {
		if c=='(' {
			x++
		} else {
			x--
			if x<0 {
				Println("No")
				return
			}
		}
	}
	if x>0 {
		Println("No")
		return
	}
	s=ReplaceAll(s,"()","(1+1)")
	s=ReplaceAll(s,")(",")+(")
	for Contains(s,"))") {
	s=ReplaceAll(s,"))",")+1)")
	}
	z:=Count(s,"1")
	if z>k {
		Println("No")
		return
	}
	s+=Repeat("+1",k-z)
	Println("Yes")
	Println(s)
}
0