結果

問題 No.1378 Flattening
ユーザー leaf_1415leaf_1415
提出日時 2020-10-14 19:39:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 750 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 63,648 KB
実行使用メモリ 199,024 KB
最終ジャッジ日時 2023-09-28 00:50:37
合計ジャッジ時間 13,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 OLE -
testcase_32 OLE -
testcase_33 OLE -
testcase_34 OLE -
testcase_35 OLE -
testcase_36 OLE -
testcase_37 OLE -
testcase_38 OLE -
testcase_39 OLE -
testcase_40 OLE -
testcase_41 OLE -
testcase_42 OLE -
testcase_43 OLE -
testcase_44 OLE -
testcase_45 WA -
testcase_46 OLE -
testcase_47 WA -
testcase_48 OLE -
testcase_49 OLE -
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0