結果

問題 No.801 エレベーター
ユーザー kappybarkappybar
提出日時 2020-05-01 13:17:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 999 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 169,244 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 15:24:55
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 126 ms
4,376 KB
testcase_14 AC 125 ms
4,376 KB
testcase_15 AC 124 ms
4,380 KB
testcase_16 AC 126 ms
4,376 KB
testcase_17 AC 123 ms
4,380 KB
testcase_18 AC 124 ms
4,380 KB
testcase_19 AC 127 ms
4,380 KB
testcase_20 AC 127 ms
4,376 KB
testcase_21 AC 127 ms
4,376 KB
testcase_22 AC 126 ms
4,384 KB
testcase_23 AC 120 ms
4,376 KB
testcase_24 AC 120 ms
4,376 KB
testcase_25 AC 119 ms
4,380 KB
testcase_26 AC 121 ms
4,376 KB
testcase_27 AC 121 ms
4,380 KB
testcase_28 AC 141 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
using pll = pair<ll,ll>;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,k;
    cin >> n >> m >> k;
    vector<P> lr(m);
    rep(i,m){
        cin >> lr[i].first >> lr[i].second;
    }
    vector<ll> a_prev(n+2,1);
    a_prev[0] = 0;
    vector<ll> a(n+2,0);
    rep(i,k){
        rep(j,m){
            int l = lr[j].first;
            int r = lr[j].second;
            ll plus = a_prev[r] - a_prev[l-1];
            a[l] = (a[l] + plus)%MOD;
            a[r+1] = (a[r+1] - plus + MOD)%MOD;
        }
        rep(c,2){
            for(int j=1;j<n+2;j++) a[j] = (a[j] + a[j-1])%MOD;
        }
        swap(a,a_prev);
        vector<ll> empty(n+2,0);
        swap(empty,a);
    }
    cout << (a_prev[n] - a_prev[n-1] + MOD)%MOD << endl;
    return 0;
}
0