結果
問題 | No.2031 Colored Brackets |
ユーザー | stng |
提出日時 | 2022-08-13 16:44:03 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 523 ms |
コンパイル使用メモリ | 81,612 KB |
実行使用メモリ | 269,408 KB |
最終ジャッジ日時 | 2023-10-25 00:50:25 |
合計ジャッジ時間 | 4,158 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
60,400 KB |
testcase_01 | AC | 42 ms
53,388 KB |
testcase_02 | AC | 56 ms
64,208 KB |
testcase_03 | AC | 72 ms
75,736 KB |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
import copy n = int(input()) s = input() mod = 998244353 dpb = [[0]*n for i in range(n)] ori = [[0]*n for i in range(n)] cnt = 1 dpb[0][1] = 1 dpb[1][0] = 1 for i in range(1,n): dpn = copy.deepcopy(ori) if s[i] == "(": cnt += 1 for j in range(cnt): dpn[cnt-1-j][j+1] += dpb[cnt-1-j][j] dpn[cnt-1-j][j+1] %= mod dpn[cnt-j][j] += dpb[cnt-1-j][j] dpn[cnt-j][j] %= mod else: for j in range(cnt): dpn[cnt-1-j][j] += dpb[cnt-j][j] dpn[cnt-1-j][j] %= mod dpn[cnt-1-j][j] += dpb[cnt-j-1][j+1] dpn[cnt-1-j][j] %= mod #print(cnt-j,j) cnt -= 1 dpb = dpn[:] #print(dpn,dpb) print(dpn[0][0]%mod)