結果
| 問題 |
No.3043 括弧列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 22:41:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 483 bytes |
| コンパイル時間 | 578 ms |
| コンパイル使用メモリ | 62,124 KB |
| 実行使用メモリ | 19,428 KB |
| 最終ジャッジ日時 | 2025-02-28 22:41:35 |
| 合計ジャッジ時間 | 2,376 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
mint dp[2001][2001];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N;
dp[0][0]=1;
for(int i=0;i<N;i++)for(int j=0;j<=i;j++)
{
dp[i+1][j+1]+=dp[i][j];
if(j)dp[i+1][j-1]+=dp[i][j];
}
mint ans=0;
for(int i=0;i<N;i++)
{
for(int p=1;p<=i;p++)
{
ans+=mint::raw(p)*dp[i][p]*dp[N-i-1][p+1];
}
}
cout<<ans.val()<<endl;
}