結果

問題 No.801 エレベーター
ユーザー sykwersykwer
提出日時 2019-03-18 15:43:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,679 bytes
コンパイル時間 2,887 ms
コンパイル使用メモリ 113,364 KB
実行使用メモリ 73,580 KB
最終ジャッジ日時 2023-09-25 13:09:18
合計ジャッジ時間 5,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 198 ms
73,516 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 194 ms
73,236 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 195 ms
73,472 KB
testcase_22 AC 195 ms
73,216 KB
testcase_23 WA -
testcase_24 AC 175 ms
73,180 KB
testcase_25 WA -
testcase_26 AC 177 ms
73,580 KB
testcase_27 AC 179 ms
73,268 KB
testcase_28 AC 196 ms
73,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    // dp[i][j]: i回の移動でj階に移動する場合の数
    // [dp[i+1][Li], dp[i+1][Ri]] <- [dp[i][Li], dp[i][Ri]]

    int N, M, K;
    cin >> N >> M >> K;

    vector<int> L(M);
    vector<int> R(M);
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        L[i]--; R[i]--;
    }

    vector<vector<int>> dp(K + 1, vector<int>(N + 1, 0));
    dp[0][0] = 1;

    for (int i = 0; i < K; i++) {
        vector<int> S(N + 1, 0);
        for (int j = 0; j < N; j++) (S[j + 1] = S[j] + dp[i][j]) %= MOD;

        for (int j = 0; j < M; j++) {
            int s = S[R[j] + 1] - S[L[j]] + MOD;
            (dp[i+1][R[j] + 1] += -s + MOD) %= MOD;
            (dp[i+1][L[j]] += s) %= MOD;
        }

        for (int j = 0; j < N; j++) (dp[i+1][j+1] += dp[i+1][j]) %= MOD;
    }

    cout << dp[K][N - 1] << endl;

    return 0;
}
0