結果
問題 |
No.3141 Balancing with X=>O Flip
|
ユーザー |
![]() |
提出日時 | 2025-05-16 23:04:14 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 409 bytes |
コンパイル時間 | 11,141 ms |
コンパイル使用メモリ | 235,788 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-16 23:04:33 |
合計ジャッジ時間 | 13,264 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
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") } }