結果
| 問題 |
No.1378 Flattening
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2020-10-14 19:39:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 59,356 KB |
| 実行使用メモリ | 198,784 KB |
| 最終ジャッジ日時 | 2024-07-20 19:23:07 |
| 合計ジャッジ時間 | 5,767 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 29 OLE * 4 -- * 17 |
ソースコード
#include <iostream>
#include <cassert>
#include <algorithm>
#define llint long long
#define mod 998244353
using namespace std;
llint n;
llint a[5005], b[5005];
llint dp[5005][5005];
int main(void)
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
assert(n >= 1 && n <= 5000);
for(int i = 1; i <= n; i++) b[i] = a[i];
sort(b+1, b+n+1);
for(int i = 1; i <= n; i++) assert(b[i] == i);
dp[0][1] = 1;
for(int i = 0; i <= n; i++){
for(int j = 1; j <= n; j++){
if(i+1 <= n && a[i+1] >= a[j]) (dp[i+1][j] += dp[i][j]) %= mod;
if(j+1 <= n) (dp[i][j+1] += dp[i][j]) %= mod;
}
}
for(int i = 0; i <= n; i++){
for(int j = 1; j <= n; j++){
cout << dp[i][j] << " ";
}
cout << endl;
}
cout << dp[n][n] << endl;
return 0;
}
leaf_1415