結果

問題 No.801 エレベーター
ユーザー 25__toma25__toma
提出日時 2019-03-26 03:20:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,242 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 175,336 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-10 20:14:14
合計ジャッジ時間 11,428 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

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<vector<ll>> way(N + 1, vector<ll>(N + 1, 0));
	REP(i, M) {
		ll l, r;
		cin >> l >> r;
		l--; r--;
		FOR(pos, l, r + 1) {
			way[pos][l]++;
			way[pos][r + 1]--;
		}
	}
	REP(i, N) REP(j, N)way[i][j + 1] += way[i][j];

	vector<vector<ll>> dp(K + 1, vector<ll>(N, 0));
	REP(i, N)dp[0][i] = 1;
	way = pow(way, K);
	cout << way[0][N-1] << endl;

	return 0;
}
0