結果

問題 No.3099 Parentheses Decomposition
ユーザー わん
提出日時 2025-05-19 00:34:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 141,184 KB
最終ジャッジ日時 2025-05-19 00:34:38
合計ジャッジ時間 15,215 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
fact = [1]
inv_fact = [1]
for i in range(5*10**5+10):
  fact.append(fact[i] * (i + 1) % MOD)
  inv_fact.append(pow(fact[i+1], MOD - 2, MOD))

def nCk(n, r):
  if r > n:
    return 0
  return (((fact[n] * inv_fact[n - r]) % MOD) * inv_fact[r]) % MOD

N = int(input())
S = input()

ans = 0
if S[N//2-1:N//2+1] == "()":
  for i in range(N//2+1):
    ans += pow(nCk(N//2, i), 2, MOD)
else:
  ans = pow(2, N//2, MOD)
print(ans%MOD)
0