結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-11 22:03:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 409 bytes |
| コンパイル時間 | 414 ms |
| コンパイル使用メモリ | 83,036 KB |
| 実行使用メモリ | 115,184 KB |
| 最終ジャッジ日時 | 2025-04-11 22:03:54 |
| 合計ジャッジ時間 | 3,416 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 RE * 1 |
ソースコード
n=int(input())
s=list(input())
mod=998244353
fact=[1]
for i in range(1,2*10**5+1):
fact.append(fact[-1]*i)
fact[-1]%=mod
def comb(a,b):
return fact[a]*pow((fact[b]*fact[a-b])%mod,mod-2,mod)
if not ("".join(s[:n//2])=="("*(n//2) and "".join(s[n//2:])==")"*(n//2)):
print(pow(2,n//2,mod))
else:
ans=0
for i in range(n//2+1):
ans+=comb(n//2,i)**2
ans%=mod
print(ans)