結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-14 15:24:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,193 bytes |
| コンパイル時間 | 2,470 ms |
| コンパイル使用メモリ | 204,924 KB |
| 最終ジャッジ日時 | 2025-01-07 06:55:29 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 10 TLE * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, K;
cin>> N >> M >> K;
vector<pair<int, int>> LR(M);
vector<vector<long long >> dp(3001, vector<long long>(3001, -1));
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
LR[i] = make_pair(a, b);
}
sort(LR.begin(), LR.end());
for (int i = 0; i < M; i++)
dp[K][i] = (N <= LR[i].second) ? 1 : 0;
auto solve = [&](auto f, int k, int m) {
if (dp[k][m] >= 0)
return dp[k][m];
long long r = 0LL;
for (int i = 0; i < upper_bound(LR.begin(), LR.end(), make_pair(LR[m].second, 0)) - LR.begin(); i++)
if (min(LR[m].second, LR[i].second) >= max(LR[m].first, LR[i].first))
r = (r + f(f, k + 1, i) * (min(LR[m].second, LR[i].second) - max(LR[m].first, LR[i].first) + 1) % 1000000007) % 1000000007;
dp[k][m] = r;
return r;
};
long long r = 0;
for (int i = 0; i < M; i++)
if (1 >= LR[i].first)
r = (r + solve(solve, 1, i)) % 1000000007;
cout << r << endl;
return 0;
}