結果

問題 No.3099 Parentheses Decomposition
ユーザー moon17
提出日時 2025-04-11 21:41:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 616 ms / 2,000 ms
コード長 234 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,776 KB
実行使用メモリ 154,256 KB
最終ジャッジ日時 2025-04-11 21:41:53
合計ジャッジ時間 5,647 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=input()
m=n//2
if s=='('*m+')'*m:
  a=2
else:
  a=1
M=998244353
N=10**6
F=[1]
for i in range(N):F+=F[i]*(i+1)%M,
c=lambda l,k:F[l]*pow(F[k]*F[l-k],M-2,M)
ans=0
for i in range(m+1):
  ans+=c(m,i)**a
  ans%=M
print(ans)
0