結果

問題 No.2031 Colored Brackets
ユーザー とりゐとりゐ
提出日時 2022-06-15 22:25:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 77,448 KB
最終ジャッジ日時 2023-10-13 20:56:43
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,228 KB
testcase_01 AC 73 ms
71,208 KB
testcase_02 AC 73 ms
71,252 KB
testcase_03 AC 77 ms
75,312 KB
testcase_04 AC 100 ms
77,196 KB
testcase_05 AC 96 ms
77,288 KB
testcase_06 AC 95 ms
77,108 KB
testcase_07 AC 74 ms
75,400 KB
testcase_08 AC 106 ms
77,160 KB
testcase_09 AC 109 ms
77,136 KB
testcase_10 AC 120 ms
77,168 KB
testcase_11 AC 112 ms
77,004 KB
testcase_12 AC 121 ms
77,232 KB
testcase_13 AC 104 ms
77,212 KB
testcase_14 AC 120 ms
77,300 KB
testcase_15 AC 123 ms
77,264 KB
testcase_16 AC 120 ms
76,984 KB
testcase_17 AC 125 ms
77,104 KB
testcase_18 AC 114 ms
77,108 KB
testcase_19 AC 116 ms
77,448 KB
testcase_20 AC 106 ms
77,324 KB
testcase_21 AC 107 ms
77,284 KB
testcase_22 AC 108 ms
77,380 KB
testcase_23 AC 120 ms
77,348 KB
testcase_24 AC 72 ms
71,068 KB
testcase_25 AC 71 ms
71,180 KB
testcase_26 AC 71 ms
71,080 KB
testcase_27 AC 76 ms
75,588 KB
testcase_28 AC 73 ms
71,088 KB
testcase_29 AC 70 ms
71,184 KB
testcase_30 AC 71 ms
71,344 KB
testcase_31 AC 81 ms
76,164 KB
testcase_32 AC 70 ms
71,288 KB
testcase_33 AC 81 ms
76,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
n=int(input())
S=input()
m=n//2+10

dp=[0]*m
dp[0]=1

now=0
for s in S:
  dpn=[0]*m
  if s=='(':
    for i in range(now+1):
      dpn[i]+=dp[i]
      if i!=m-1:
        dpn[i+1]+=dp[i]
    now+=1
  else:
    for i in range(now+1):
      dpn[i]+=dp[i]
      if i!=0:
        dpn[i-1]+=dp[i]
    now-=1
  
  dp=[i%mod for i in dpn]
if now==0:
  print(dp[0])
else:
  print(0)
0