結果

問題 No.801 エレベーター
ユーザー snrnsidysnrnsidy
提出日時 2021-05-03 22:53:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,507 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 131,908 KB
実行使用メモリ 74,068 KB
最終ジャッジ日時 2023-09-29 19:02:24
合計ジャッジ時間 5,386 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 5 ms
10,240 KB
testcase_04 AC 5 ms
10,196 KB
testcase_05 AC 4 ms
10,184 KB
testcase_06 AC 5 ms
10,164 KB
testcase_07 AC 5 ms
10,212 KB
testcase_08 AC 5 ms
10,176 KB
testcase_09 AC 5 ms
10,196 KB
testcase_10 AC 4 ms
10,168 KB
testcase_11 AC 5 ms
10,192 KB
testcase_12 AC 4 ms
10,448 KB
testcase_13 AC 181 ms
74,008 KB
testcase_14 AC 182 ms
74,068 KB
testcase_15 AC 181 ms
73,780 KB
testcase_16 AC 185 ms
73,800 KB
testcase_17 AC 183 ms
73,840 KB
testcase_18 AC 181 ms
73,828 KB
testcase_19 AC 181 ms
73,936 KB
testcase_20 AC 181 ms
73,900 KB
testcase_21 AC 182 ms
74,068 KB
testcase_22 AC 182 ms
74,028 KB
testcase_23 AC 158 ms
73,808 KB
testcase_24 AC 158 ms
73,860 KB
testcase_25 AC 158 ms
73,792 KB
testcase_26 AC 158 ms
73,892 KB
testcase_27 AC 157 ms
73,724 KB
testcase_28 AC 156 ms
73,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>
#include <random>

using namespace std;

const long long int MOD = 1e9 + 7;
long long int dp[3001][3001];
long long int psum[3001];
vector <int> l[3001];
vector <int> r[3001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K, L, R;

	cin >> N >> M >> K;

	for (int i = 0; i < M; i++)
	{
		cin >> L >> R;
		l[L].push_back(R);
		r[R].push_back(L);
	}

	dp[0][1] = 1;

	for (int i = 0; i < K; i++)
	{
		psum[1] = dp[i][1];
		for (int j = 2; j <= N; j++)
		{
			psum[j] = psum[j - 1] + dp[i][j];
			psum[j] %= MOD;
		}
		long long int val = 0;
		for (int L = 1; L <= N; L++)
		{
			for (auto R : l[L])
			{
				long long int temp = psum[R] - psum[L - 1];
				temp %= MOD;
				if (temp < 0)
				{
					temp += MOD;
				}
				val += temp;
				val %= MOD;
			}
			dp[i + 1][L] = val;
			for (auto R : r[L])
			{
				long long int temp = psum[L] - psum[R - 1];
				temp %= MOD;
				if (temp < 0)
				{
					temp += MOD;
				}
				val -= temp;
				val %= MOD;
				if (val < 0)
				{
					val += MOD;
				}
			}
		}
	}

	cout << dp[K][N] << '\n';

	return 0;
}
0