結果

問題 No.801 エレベーター
ユーザー 25__toma25__toma
提出日時 2019-03-26 03:34:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,405 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 172,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 03:55:38
合計ジャッジ時間 3,753 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 44 ms
5,376 KB
testcase_14 AC 44 ms
5,376 KB
testcase_15 AC 42 ms
5,376 KB
testcase_16 AC 44 ms
5,376 KB
testcase_17 AC 46 ms
5,376 KB
testcase_18 AC 47 ms
5,376 KB
testcase_19 AC 42 ms
5,376 KB
testcase_20 AC 43 ms
5,376 KB
testcase_21 AC 43 ms
5,376 KB
testcase_22 AC 43 ms
5,376 KB
testcase_23 AC 41 ms
5,376 KB
testcase_24 AC 41 ms
5,376 KB
testcase_25 AC 41 ms
5,376 KB
testcase_26 AC 41 ms
5,376 KB
testcase_27 AC 40 ms
5,376 KB
testcase_28 AC 46 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

using vec = vector<ll>;
using mat = vector<vec>;

mat mul(mat& A, mat& B) {
	mat C(A.size(), vec(B[0].size()));
	REP(i, A.size())REP(k, B.size())REP(j, B[0].size())
		C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
	return C;
}

mat pow(mat A, ll n) {
	mat B(A.size(), vec(A.size()));
	REP(i, A.size())B[i][i] = 1;
	while (n > 0) {
		if (n & 1)B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}

int main()
{
	ll N, M, K;
	cin >> N >> M >> K;
	vector<pair<ll, ll>> LR(M);
	REP(i, M) {
		ll l, r;
		cin >> l >> r;
		LR[i] = { l,r };
	}

	vector<ll> cur(N + 2, 0), next(N + 2, 0);
	cur[1]++;
	REP(_, K) {
		// ruiseki
		REP(i, N + 1)cur[i + 1] += cur[i];
		for (auto lr : LR) {
			ll sum = cur[lr.second] - cur[lr.first - 1];

			// imos
			next[lr.first] += sum;
			next[lr.second + 1] -= sum;
		}
		REP(i, N + 1)next[i + 1] += next[i];

		// fix
		for (auto& num : next)num %= MOD;
		cur = next;
		next = vector<ll>(N + 2, 0);
	}
	cout << cur[N] << endl;

	return 0;
}
0