結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
commy
|
| 提出日時 | 2019-03-30 19:46:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,026 bytes |
| コンパイル時間 | 819 ms |
| コンパイル使用メモリ | 80,532 KB |
| 実行使用メモリ | 73,728 KB |
| 最終ジャッジ日時 | 2024-11-16 19:36:27 |
| 合計ジャッジ時間 | 34,300 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 TLE * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif
using namespace std;
typedef long long int ll;
template<typename T>
vector<T> make_v(size_t a, T b) {
return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}
const ll mod = 1000000007;
class SegmentTree {
vector<ll> data;
int N;
public:
SegmentTree(int n) {
N = 1;
while (N < n) N *= 2;
data.resize(2 * N - 1, 0LL);
}
void add(int l, int r, ll val) {
add(l, r, 0, N, 0, val);
}
void add(int l, int r, int a, int b, int x, ll val) {
if (b <= l || r <= a) return;
if (l <= a && b <= r) {
data[x] = (data[x] + val) % mod;
return;
}
int mid = (a + b) / 2;
add(l, r, a, mid, 2 * x + 1, val);
add(l, r, mid, b, 2 * x + 2, val);
}
ll get(int pos) {
pos += N - 1;
ll ans = data[pos];
while (pos > 0) {
pos = (pos - 1) / 2;
ans = (ans + data[pos]) % mod;
}
return ans;
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
vector<int> L(m), R(m);
REP(i, 0, m) {
cin >> L[i] >> R[i];
}
auto dp = make_v(k + 1, n, 0LL);
dp[0][0] = 1;
REP(i, 0, k) {
SegmentTree segtree(n);
vector<ll> sum(n + 1, 0LL);
REP(j, 0, n) {
sum[j + 1] = (sum[j] + dp[i][j]) % mod;
}
REP(j, 0, m) {
ll a = (sum[R[j]] - sum[L[j] - 1] + mod) % mod;
segtree.add(L[j] - 1, R[j], a);
}
REP(j, 0, n) {
dp[i + 1][j] = segtree.get(j);
}
}
cout << dp[k][n - 1] << endl;
return 0;
}
commy