結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
おもち(求肥)
|
| 提出日時 | 2025-04-11 21:52:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 460 bytes |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 82,668 KB |
| 実行使用メモリ | 848,528 KB |
| 最終ジャッジ日時 | 2025-04-11 21:52:53 |
| 合計ジャッジ時間 | 4,148 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 4 MLE * 1 -- * 15 |
ソースコード
import sys
sys.setrecursionlimit(10**7)
from functools import cache
MOD=998244353
@cache
def factorial(d):
if d == 0 or d == 1:
return 1
else:
return (d * factorial(d - 1))
N=int(input())
n=N//2
S=input()
if S[0]!=S[1]:
type=1
else:
type=0
if type==1:
ans = 1
for i in range(n):
ans=(ans*2)%MOD
else:
ans = 0
for r in range(0, n+1):
x=factorial(n)//factorial(n-r)//factorial(r)
ans = (ans + x*x)%MOD
print(ans)
おもち(求肥)