結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー ID 21712
提出日時 2025-05-16 23:43:31
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 14,627 ms
コンパイル使用メモリ 237,780 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-17 00:37:30
合計ジャッジ時間 18,826 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 i:=0;i<5;i++ {
	s=ReplaceAll(s,"))",")+1)")
	}
	z:=Count(s,"1")
	if z>k {
		Println("No")
		return
	}
	s+=Repeat("+1",k-z)
	Println("Yes")
	Println(s)
}
0