結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
25__toma
|
| 提出日時 | 2019-03-26 03:34:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,405 bytes |
| コンパイル時間 | 1,763 ms |
| コンパイル使用メモリ | 177,096 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 20:32:37 |
| 合計ジャッジ時間 | 3,520 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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;
}
25__toma