結果

問題 No.2031 Colored Brackets
ユーザー stng
提出日時 2022-08-08 18:20:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 60,844 KB
最終ジャッジ日時 2024-09-19 03:35:58
合計ジャッジ時間 2,667 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 7 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()

mod = 998244353
#ans = 1
ans = 1
lt = 0
tmp = 1
for i in range(n):
    if s[i] == "(":
        lt += 1
    else:
        if lt > 1:
            tmp *= lt*2
        tmp %= mod
        lt -= 1
        if lt == 0:
            if tmp == 1:
                tmp = 2
            else:
                tmp += 2
            ans *= tmp
            ans %= mod
            tmp = 1

print(ans%mod)
0