結果
| 問題 | No.801 エレベーター |
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-03-18 21:30:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 219 ms / 2,000 ms |
| コード長 | 1,481 bytes |
| 記録 | |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 101,588 KB |
| 実行使用メモリ | 73,728 KB |
| 最終ジャッジ日時 | 2024-07-19 04:50:52 |
| 合計ジャッジ時間 | 5,285 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;
int main() {
int N,M,K;
cin >> N >> M >> K;
vector<Pii> elevators(M);
for(int i=0;i<M;++i) {
cin >> elevators[i].first >> elevators[i].second;
}
vector< vector<ll> > dp(K+1, vector<ll>(N+2, 0LL));
dp[0][1] = 1LL;
for(int i=0;i<K;++i) {
for(int j=1;j<=N+1;++j) {
dp[i][j] += dp[i][j-1];
dp[i][j] %= MOD;
}
for(int j=0;j<M;++j) {
if(!dp[i][elevators[j].first]) continue;
ll total = (dp[i][elevators[j].second] - dp[i][elevators[j].first-1] + MOD) % MOD;
dp[i+1][elevators[j].first] += total;
dp[i+1][elevators[j].first] %= MOD;
dp[i+1][elevators[j].second+1] += MOD - total;
dp[i+1][elevators[j].second+1] %= MOD;
}
for(int j=1;j<=N+1;++j) {
dp[i+1][j] += dp[i+1][j-1];
dp[i+1][j] %= MOD;
}
}
cout << dp[K][N] << endl;
}
noisy_noimin