結果

問題 No.801 エレベーター
ユーザー sugarrrsugarrr
提出日時 2019-03-20 23:03:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,589 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 174,812 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-10-19 04:37:42
合計ジャッジ時間 6,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 65 ms
4,348 KB
testcase_04 AC 67 ms
4,348 KB
testcase_05 AC 64 ms
4,348 KB
testcase_06 AC 64 ms
4,348 KB
testcase_07 AC 67 ms
4,348 KB
testcase_08 AC 69 ms
4,348 KB
testcase_09 AC 65 ms
4,348 KB
testcase_10 AC 67 ms
4,348 KB
testcase_11 AC 64 ms
4,348 KB
testcase_12 AC 66 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){
    pos+=val;
    if(pos>=i_7){
        pos=mod(pos);
    }
}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
// 区間加算区間和
struct RSQRAQ {
    ll n;
    vector<ll> dat, lazy;
    RSQRAQ(){}
    void start(ll n_) {
        n = 1; while(n < n_) n *= 2;
        dat.assign(n*2, 0);
        lazy.assign(n*2, 0);
    }
    void eval(ll len, ll k) {
        if(lazy[k] == 0) return;
        if(k*2+1 < n*2-1) {
            Add(lazy[2*k+1] , lazy[k]);
            Add(lazy[2*k+2] , lazy[k]);
        }
        Add(dat[k] , lazy[k]*len);
        lazy[k] = 0;
    }
    // [a, b)にxを加える
    ll update(ll a, ll b, ll x, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return dat[k];
        if(a <= l && r <= b) {
            Add(lazy[k] , x);
            return mod(dat[k] + lazy[k]*(r-l));
        }
        return dat[k] = mod(update(a, b, x, 2*k+1, l, (l+r)/2) + update(a, b, x, 2*k+2, (l+r)/2, r));
    }
    ll update(ll a, ll b, ll x) { return update(a, b, x, 0, 0, n); }
    // [a, b)の和を求める
    ll query(ll a, ll b, ll k, ll l, ll r) {
        eval(r-l, k);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return mod(vl + vr);
    }
    ll query(ll a, ll b) { return query(a, b, 0, 0, n); }
};
//セグ木なので番号は0~n-1
/////////////////////////////////////////

int main(){fastio;
    ll n,m,k;cin>>n>>m>>k;
    ll ele[m][2];
    rep(i,0,m-1)rep(j,0,1){
        cin>>ele[i][j];
        ele[i][j]--;
    }
    RSQRAQ u[2];
    rep(i,0,1)u[i].start(n);
    u[0].update(0,1,1);
    rep(q,1,k){
        u[q&1].start(n);
        rep(i,0,m-1){
            ll sum=u[(q-1)&1].query(ele[i][0],ele[i][1]+1);
            u[q&1].update(ele[i][0],ele[i][1]+1,sum);
        }
    }
    cout<<u[k&1].query(n-1,n)<<endl;
    
    
    
    return 0;
}






0