結果
問題 | No.801 エレベーター |
ユーザー |
|
提出日時 | 2025-03-13 14:24:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 1,167 bytes |
コンパイル時間 | 3,834 ms |
コンパイル使用メモリ | 280,552 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-13 14:24:59 |
合計ジャッジ時間 | 6,434 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using ll = long long; using mint = atcoder::modint1000000007; using vi = vector<int>; #define rep1(a) for(ll i = 0; i < ll(a); i++) #define rep2(i, a) for(ll i = 0; i < ll(a); i++) #define rep3(i, a, b) for(ll i = ll(a); i < ll(b); i++) #define rep4(i, a, b, c) for(ll i = ll(a); i < ll(b); i += ll(c)) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define all(x) begin(x),end(x) #define rall(x) rbegin(x),rend(x) int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int N, M, K; cin >> N >> M >> K; vector<pair<int, int>> I(M); rep(i, M) { int l, r; cin >> l >> r; I[i] = {--l, r}; } vector<mint> dp(N + 1); dp[0] = 1; rep(i, K) { vector<mint> ndp(N + 1); vector<mint> pref(N + 2); rep(j, N + 1) pref[j + 1] = pref[j] + dp[j]; rep(j, M) { const auto&[l, r] = I[j]; mint sum = pref[r] - pref[l]; ndp[l] += sum; ndp[r] -= sum; } rep(j, 1, N + 1) ndp[j] += ndp[j - 1]; swap(dp, ndp); } mint ans = dp[N - 1]; cout << ans.val( ) << endl; }