結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-04-11 21:45:16 |
| 言語 | Go (1.23.4) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 531 bytes |
| コンパイル時間 | 20,762 ms |
| コンパイル使用メモリ | 257,100 KB |
| 実行使用メモリ | 7,896 KB |
| 最終ジャッジ日時 | 2025-04-11 21:45:42 |
| 合計ジャッジ時間 | 21,902 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]=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