結果
問題 |
No.3143 Colorless Green Parentheses Sleep Furiously
|
ユーザー |
![]() |
提出日時 | 2025-05-17 00:04:30 |
言語 | Go (1.23.4) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 661 bytes |
コンパイル時間 | 17,488 ms |
コンパイル使用メモリ | 244,084 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-17 00:38:35 |
合計ジャッジ時間 | 17,638 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 WA * 1 |
ソースコード
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 y:=0 for _,c:=range s { if c=='(' { x++ } else { x-- if x<0 { Println("No") return } if x==0 { y++ } } } 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 } if z==k&&y==1 { Println("No") return } s+=Repeat("+1",k-z) Println("Yes") Println(s) }