結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-04-13 14:46:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 446 ms / 2,000 ms |
| コード長 | 737 bytes |
| コンパイル時間 | 487 ms |
| コンパイル使用メモリ | 82,120 KB |
| 実行使用メモリ | 142,640 KB |
| 最終ジャッジ日時 | 2025-04-13 14:46:37 |
| 合計ジャッジ時間 | 5,351 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
class CP:
def __init__(self, N):
self.fact = [1]
self.fact_inv = [1]
for i in range(1, N+1):
self.fact.append((self.fact[-1]*i)%MOD)
self.fact_inv.append(pow(self.fact[-1], -1, MOD))
def C(self, N, K):
if N >= K:
return self.fact[N]*self.fact_inv[K]%MOD*self.fact_inv[N-K]%MOD
else:
return 0
def P(self, N, K):
if N >= K:
return self.fact[N]*self.fact_inv[N-K]%MOD
else:
return 0
N = int(input())
S = input()
MOD = 998244353
cp = CP(N)
if S[:2] == "()":
print(pow(2, N//2, MOD))
else:
ans = 0
for i in range(N//2+1):
ans += cp.C(N//2, i)**2
ans %= MOD
print(ans)
detteiuu