結果

問題 No.2031 Colored Brackets
ユーザー どららどらら
提出日時 2022-08-05 22:49:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,006 bytes
コンパイル時間 4,517 ms
コンパイル使用メモリ 234,884 KB
実行使用メモリ 7,148 KB
最終ジャッジ日時 2023-10-14 00:24:06
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,356 KB
testcase_20 AC 3 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 1 ms
4,352 KB
testcase_28 AC 2 ms
4,356 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 4 ms
4,552 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
using mint = modint998244353;


map<pair<int,int>,mint> dp[3005];

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  dp[0][make_pair(0,0)] = 1;
  rep(i,N){
    FOR(it,dp[i]){
      mint x = it->second;
      int j = (it->first).first;
      int k = (it->first).second;
      if(S[i] == '('){
        if(j+1<105) dp[i+1][make_pair(j+1,k)] += x;
        if(k+1<105) dp[i+1][make_pair(j,k+1)] += x;
      }
      if(S[i] == ')'){
        if(j-1>=0) dp[i+1][make_pair(j-1,k)] += x;
        if(k-1>=0) dp[i+1][make_pair(j,k-1)] += x;
      }
    }
  }

  cout << dp[N][make_pair(0,0)].val() << endl;
  
  return 0;
}

0