結果

問題 No.1877 俺自身が線グラフになることだ
ユーザー 👑 colognecologne
提出日時 2022-03-17 16:10:05
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 117,568 KB
実行使用メモリ 11,032 KB
最終ジャッジ日時 2023-07-26 19:08:30
合計ジャッジ時間 1,808 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 19 ms
11,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <iostream>
#include <optional>
#include <vector>
#include <atcoder/modint>

using namespace std;
using Mint = atcoder::modint1000000007;

int main()
{
	int N;
	cin >> N;
	vector<vector<optional<Mint>>> DP(N + 1, vector<optional<Mint>>(N + 1));
	function<Mint(int, int)> f = [&](int a, int b)
	{
		if (a == 0)
			return Mint(1);
		if (b > a)
			return Mint(0);
		if (DP[a][b])
			return *DP[a][b];
		return *(DP[a][b] = f(a - b, b) + f(a, b + 1));
	};
	cout << f(N, 3).val() << endl;
}
0