結果

問題 No.801 エレベーター
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-03-18 21:30:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,481 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 100,028 KB
実行使用メモリ 73,656 KB
最終ジャッジ日時 2023-09-26 09:56:26
合計ジャッジ時間 5,558 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 216 ms
73,468 KB
testcase_14 AC 215 ms
73,500 KB
testcase_15 AC 214 ms
73,232 KB
testcase_16 AC 217 ms
73,240 KB
testcase_17 AC 216 ms
73,444 KB
testcase_18 AC 215 ms
73,396 KB
testcase_19 AC 216 ms
73,208 KB
testcase_20 AC 216 ms
73,200 KB
testcase_21 AC 216 ms
73,468 KB
testcase_22 AC 216 ms
73,396 KB
testcase_23 AC 197 ms
73,208 KB
testcase_24 AC 197 ms
73,272 KB
testcase_25 AC 196 ms
73,240 KB
testcase_26 AC 197 ms
73,656 KB
testcase_27 AC 196 ms
73,276 KB
testcase_28 AC 197 ms
73,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0