結果

問題 No.801 エレベーター
ユーザー yuji9511yuji9511
提出日時 2019-03-18 13:15:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,994 bytes
コンパイル時間 1,868 ms
コンパイル使用メモリ 145,032 KB
実行使用メモリ 74,184 KB
最終ジャッジ日時 2023-09-25 08:52:34
合計ジャッジ時間 7,017 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 6 ms
5,224 KB
testcase_04 AC 5 ms
5,312 KB
testcase_05 AC 6 ms
5,292 KB
testcase_06 AC 6 ms
5,540 KB
testcase_07 AC 5 ms
5,524 KB
testcase_08 AC 6 ms
5,336 KB
testcase_09 AC 6 ms
5,276 KB
testcase_10 AC 6 ms
5,252 KB
testcase_11 AC 5 ms
5,288 KB
testcase_12 AC 5 ms
5,396 KB
testcase_13 AC 234 ms
74,024 KB
testcase_14 AC 232 ms
73,984 KB
testcase_15 AC 232 ms
73,772 KB
testcase_16 AC 231 ms
73,760 KB
testcase_17 AC 233 ms
73,900 KB
testcase_18 AC 231 ms
73,884 KB
testcase_19 AC 232 ms
73,984 KB
testcase_20 AC 231 ms
73,916 KB
testcase_21 AC 232 ms
74,024 KB
testcase_22 AC 230 ms
74,184 KB
testcase_23 AC 223 ms
73,912 KB
testcase_24 AC 223 ms
73,804 KB
testcase_25 AC 226 ms
73,832 KB
testcase_26 AC 225 ms
74,068 KB
testcase_27 AC 224 ms
73,972 KB
testcase_28 AC 225 ms
73,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18 + 7)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll dp[3010][3010] = {};// dp[i][j]: i回の移動の後、j階にいるような乗り方の総数
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,K;
    ll L[3010], R[3010];
    cin >> N >> M >> K;
    rep(i,0,M) cin >> L[i] >> R[i];
    // ll dp_cur[3010] = {}, dp_next[3010] = {};
    // dp_cur[1] = 1;
    // rep(i,0,K){
    //     memset(dp_next, 0, sizeof(dp_next));
    //     ll sum[3010] = {};
    //     rep(i,0,N+1) sum[i+1] = (sum[i] + dp_cur[i]) % MOD;
    //     rep(i,0,M){
    //         ll v = (sum[R[i]+1] - sum[L[i]] + MOD) % MOD;
    //         dp_next[L[i]] += v % MOD;
    //         dp_next[L[i]] %= MOD;
    //         dp_next[R[i]+1] += (MOD - v) % MOD;
    //         dp_next[R[i]+1] %= MOD;
    //     }
    //     rep(i,0,N+1){
    //         dp_next[i+1] += dp_next[i];
    //         dp_next[i+1] %= MOD;
    //     }
    //     rep(i,0,N+1) dp_cur[i] = dp_next[i];
    // }
    // print(dp_cur[N]);
    dp[0][1] = 1;
    rep(i,0,K){
        ll val[3010] = {};
        rep(j,0,N+1) val[j+1] = (val[j] + dp[i][j]) % MOD;
        rep(j,0,M){
            ll v = (val[R[j]+1] - val[L[j]] + MOD) % MOD;
            dp[i+1][L[j]] += v;
            dp[i+1][L[j]] %= MOD;
            dp[i+1][R[j]+1] += (MOD - v) % MOD;
            dp[i+1][R[j]+1] %= MOD;
        }
        rep(j,0,N+1){
            dp[i+1][j+1] += dp[i+1][j];
            dp[i+1][j+1] %= MOD;
        }
    }
    print(dp[K][N]);
    



 }
0