結果
| 問題 |
No.3099 Parentheses Decomposition
|
| コンテスト | |
| ユーザー |
おもち(求肥)
|
| 提出日時 | 2025-04-11 21:50:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 419 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 82,192 KB |
| 実行使用メモリ | 80,340 KB |
| 最終ジャッジ日時 | 2025-04-11 21:51:02 |
| 合計ジャッジ時間 | 2,281 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 RE * 5 |
ソースコード
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)
おもち(求肥)