結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-04-11 21:49:05 |
| 言語 | Go (1.23.4) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 533 bytes |
| コンパイル時間 | 17,252 ms |
| コンパイル使用メモリ | 235,128 KB |
| 実行使用メモリ | 7,892 KB |
| 最終ジャッジ日時 | 2025-04-11 21:49:26 |
| 合計ジャッジ時間 | 18,663 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 2 |
| other | AC * 11 RE * 9 |
ソースコード
package main
import . "fmt"
import . "math/big"
const M=998244353
func main() {
var n int
var s string
Scan(&n,&s)
if s[1]==')' {
Println(new(Int).Exp(NewInt(2),NewInt(int64(n/2)),NewInt(M)))
return
}
c:=make([]int,n/2+1)
c[0]=1
for i:=range c[1:] {
c[i+1]=c[i]*(i+1)%M
}
d:=make([]int,n/2+1)
d[n/2]=int(new(Int).ModInverse(NewInt(int64(c[n])),NewInt(M)).Int64())
for i:=n/2;i>0;i-- {
d[i-1]=d[i]*i%M
}
var ans int
for i:=0;i<=n/2;i++ {
x:=c[n/2]*d[i]%M*d[n/2-i]%M
ans+=x*x%M
ans%=M
}
Println(ans)
}
ID 21712