結果

問題 No.801 エレベーター
ユーザー satashunsatashun
提出日時 2019-03-17 21:33:05
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 1,032 ms
使用メモリ 74,292 KB
最終ジャッジ日時 2023-02-11 04:35:11
合計ジャッジ時間 5,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
6,952 KB
testcase_01 AC 2 ms
6,952 KB
testcase_02 AC 1 ms
4,904 KB
testcase_03 AC 5 ms
10,296 KB
testcase_04 AC 4 ms
10,244 KB
testcase_05 AC 4 ms
10,180 KB
testcase_06 AC 4 ms
10,276 KB
testcase_07 AC 4 ms
10,180 KB
testcase_08 AC 4 ms
10,248 KB
testcase_09 AC 4 ms
10,328 KB
testcase_10 AC 4 ms
10,172 KB
testcase_11 AC 3 ms
10,248 KB
testcase_12 AC 3 ms
10,176 KB
testcase_13 AC 210 ms
74,212 KB
testcase_14 AC 212 ms
74,272 KB
testcase_15 AC 212 ms
74,132 KB
testcase_16 AC 217 ms
74,036 KB
testcase_17 AC 212 ms
74,184 KB
testcase_18 AC 213 ms
74,132 KB
testcase_19 AC 213 ms
74,216 KB
testcase_20 AC 214 ms
74,160 KB
testcase_21 AC 214 ms
74,264 KB
testcase_22 AC 212 ms
74,292 KB
testcase_23 AC 191 ms
74,096 KB
testcase_24 AC 189 ms
74,032 KB
testcase_25 AC 189 ms
74,184 KB
testcase_26 AC 189 ms
74,156 KB
testcase_27 AC 188 ms
74,084 KB
testcase_28 AC 186 ms
74,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;
const int MX = 3010;

ll dp[MX][MX], pref[MX];
int L[MX], R[MX];
vi in[MX], out[MX];

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	rep(i, M) {
		cin >> L[i] >> R[i];
		--L[i];
		in[L[i]].pb(i);
		out[R[i]].pb(i);
	}

	dp[0][0] = 1;
	for (int i = 1; i <= K; ++i) {
		pref[0] = 0;
		rep(j, N) {
			pref[j + 1] = (pref[j] + dp[i-1][j]) % MOD;
		}

		ll s = 0;

		for (int j = 0; j <= N; ++j) {
			for (auto t : in[j]) {
				s += (pref[R[t]] - pref[L[t]]) % MOD;
				s %= MOD;
				if (s < 0) s += MOD;
			}
			for (auto t : out[j]) {
				s -= (pref[R[t]] - pref[L[t]]) % MOD;
				s %= MOD;
				if (s < 0) s += MOD;
			}
			dp[i][j] = s;
		}
	}

	cout << dp[K][N-1] << endl;
	return 0;
}
0