結果
| 問題 |
No.3141 Balancing with X=>O Flip
|
| コンテスト | |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-05-16 23:03:29 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 407 bytes |
| コンパイル時間 | 16,871 ms |
| コンパイル使用メモリ | 250,608 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-05-16 23:03:49 |
| 合計ジャッジ時間 | 16,822 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 23 WA * 2 |
ソースコード
package main
import . "fmt"
func main(){
var n int
var s string
Scan(&n,&s)
if n%2==1 {
Println("No")
return
}
bs:=[]byte(s)
x,y:=0,0
for i,c:=range bs {
if c=='(' {
x++
} else if x>0 {
x--
} else {
y++
}
for i>=0&&y>0&&bs[i]==')'&&i+1<n&&bs[i+1]=='(' {
bs[i]='('
bs[i+1]=')'
y--
x++
i--
}
}
if x==0&&y==0 {
Println("Yes")
} else {
Println("No")
}
}
ID 21712