結果

問題 No.3043 括弧列の数え上げ
ユーザー umezo
提出日時 2025-03-04 05:28:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 3,525 ms
コンパイル使用メモリ 275,356 KB
実行使用メモリ 17,888 KB
最終ジャッジ日時 2025-03-04 05:28:16
合計ジャッジ時間 5,372 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include<bits/stdc++.h>
using namespace std;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;//B(n,V<int>(n))

const int MOD=998244353;
ll A[1010][1010];
ll B[1010][1010];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  if(n%2){
    cout<<0<<endl;
    return 0;
  }
  A[0][0]=1,B[n/2][n/2]=1;
  rep(i,n/2+1) rep(j,n/2+1){
    if(i>j) continue;
    if(i) A[i][j]=(A[i][j]+A[i-1][j])%MOD;
    if(j) A[i][j]=(A[i][j]+A[i][j-1])%MOD;
  }
  for(int i=n/2;i>=0;i--) for(int j=n/2;j>=0;j--){
    if(i>j) continue;
    if(i<n/2) B[i][j]=(B[i][j]+B[i+1][j])%MOD;
    if(j<n/2) B[i][j]=(B[i][j]+B[i][j+1])%MOD;
  }
  ll ans=0;
  rep(i,n/2+1) rep(j,n/2+1){
    if(j-i<2) continue;
    ans=(ans+A[i][j]*B[i][j]%MOD)%MOD;
  }
  cout<<ans<<endl;
  
  return 0;
}
0